Sort by highest value

Hi

I am trying to create a query to sort the last field of each measurement descending.

This is my query:

from(bucket: "iobroker")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "loxone.0.1990ece5-000b-a827-ffffb2ef6a95b230.value" or r["_measurement"] == "loxone.0.167f5741-037a-8b3d-ffffb2ef6a95b230.value" or r["_measurement"] =="loxone.0.1826dbac-0057-2552-ffffb2ef6a95b230.value")
  |> filter(fn: (r) => r["_field"] == "value")

This will show the output like this (in Grafana)

57
1.23
21.6

i wish to have it like:
57
21.6
1.23

This is the raw data:

I tried to use the sort and group functions but the results always come out weird. I cant seem to figure out what the correct syntax or functions are to accomplish this.

Kind regards
Kevin

If you use Grafana (9+), you can sort it there.

Use the Transform panel that is next to the Query tab and look for the Sort by function:

Hi

Will this not just sort by time? I want to sort so i can see the highest value first. If i try your solution:

I would presume i need to do the sorting in the flux query itself?

In Data explorer from influxDB the follwing query works, but i cannot paste this in grafana, it doenst show any value.

from(bucket: "iobroker")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "loxone.0.1990ece5-000b-a827-ffffb2ef6a95b230.value" or r["_measurement"] == "loxone.0.167f5741-037a-8b3d-ffffb2ef6a95b230.value" or r["_measurement"] == "loxone.0.1826dbac-0057-2552-ffffb2ef6a95b230.value")
  |> filter(fn: (r) => r["_field"] == "value")
  |> sort(columns: ["_time"], desc: true)
  |> last()
  |> group(columns: ["_result"], mode:"by")
  |> sort(columns: ["_value"], desc: true)

Kind regards
Kevin