How to sort tables in Flux?

I have a simple problem but I can’t seem to get over with.
I’m trying to group my data by service name, then count how many in each service.
from(bucket: “xxxs”)
|> range(start: -30m, stop: now())
|> group(columns: [“service”], mode:“by”)
|> aggregateWindow(every: 1h, fn: count, createEmpty: false)
|> sort(columns: [“value”])

So the result is like:
table0 timestamp ServiceA 10
table1 timestamp ServiceB 23
table2 timestamp ServiceC 5

What I like to do is sort “tables” by the value inside tables so it looks like:
table1 timestamp ServiceB 23
table0 timestamp ServiceA 10
table2 timestamp ServiceC 5

I understand I can use “group()” to merge them into one table then sort but I’d like to keep them in different tables for Grafana bar gauge display. I simply can’t find a way to change the order of tables.
Any hint would be appreciated!
Thanks.

I think the trick is to ungroup, sort, then regroup.

I don’t know how well this will perform, might get slow if you have a lot of data to crunch through

(Untested)

from(bucket: “xxxs”)
|> range(start: -30m, stop: now())
|> group(columns: [“service”], mode:“by”)
|> aggregateWindow(every: 1h, fn: count, createEmpty: false)
|> group()
|> sort(columns: [“value”])
|> group(columns: [“service”], mode:“by”)

This does not work for me. As soon as I regroup the data becomes sorted by the group fields instead of the field from the sort(), at least as long as _field is one of the group fields, which I think is necessary for Grafana.