Skip to main content

Ordering

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("https://raw-tutorial.s3.eu-west-1.amazonaws.com/Lokad_Orders.csv"),
subset = Collection.Filter(table, d -> d.Date == day)
in Collection.OrderBy(subset, row -> row.Quantity, "DESC", row -> row.NetAmount, "ASC")
info

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:

/tutorial/4-order?day=<date>

For instance:

/tutorial/4-order?day=2017-12-04