Flux sort() function not working on grouped data

I’m an InfluxDB2 and Flux newbie, I’m learning how to use flux and wondered if someone can help with a problem. I have a query that groups records by a tag and then I want to order those grouped results. I’m using the sort() function, but no matter where I put it in the query it will not sort on the tag. The query is:

from(bucket: "default")
  |> range (start: -1d)
  |> filter(fn: (r) => r["_measurement"] == "batch_results")
  |> filter(fn: (r) => r["_field"] == "batch_start")
  |> group(columns: ["batch"])
  |> last()
  |> sort(columns: ["batch"], desc: true)

The query results are in ascending order of the “batch” tag, but I need them in descending order. Do I need a different function for this?

Hey, did you ever find a solution? I’m running into the same issue where I cannot sort by a grouped column.

Hello @KyrumX,
What does your data look like? Are you expecting to sort alphabetically? Can you please share example input and expected output? Thank you!

Hi, apologies for the late response and thank you for your reply.
It seems to be working just fine now. I can only imagine it was user error with a manual UI override enabled somewhere.