Skip to main content


Learn how to order data.

A collection can be ordered using Collection.OrderBy. A list can be ordered using List.OrderBy.

In the example, a dataset is read and filtered. The resulting collection is then ordered: first by column Quantity in descending order, then by column NetAmount in ascending order. The ordering on NetAmount applies when two rows have the same value as Quantity:

let table = Csv.InferAndRead(""),
subset = Collection.Filter(table, d -> d.Date == day)
in Collection.OrderBy(subset, row -> row.Quantity, "DESC", row -> row.NetAmount, "ASC")

If you want to try this example, you can deploy the following endpoint:

Tutorial 4 - Order data in a collection
Learn how to sort elements in a collection.

Sample usage:


For instance: