Table.Sort

It arranges the table by using a list of one or more column names and optional comparison criteria, specified in the format { { col1, comparison criteria }, { col2 } }.

Syntax

Table.Sort(table as table, comparisonCriteria as any) as table

About

It arranges the table by using a list of one or more column names and optional comparison criteria, specified in the format { { col1, comparison criteria }, { col2 } }.

Explanation

Example 1 Arrange the table based on the "OrderID" column. Usage: In Power Query M language, use MTable.Sort function to sort the table on the "OrderID" column. Output: The table will be sorted based on the "OrderID" column in ascending order. Example 2 Sort the table on the "OrderID" column in descending order. Usage: Using Power Query M language, use MTable.Sort function to sort the table on the "OrderID" column in descending order. Output: The table will be sorted based on the "OrderID" column in descending order. Example 3 Sort the table first by "CustomerID" in ascending order, then by "OrderID". Usage: Using Power Query M language, utilize the MTable.Sort function to first sort the table by "CustomerID" in ascending order, and then by "OrderID". Output: The table will be sorted first by "CustomerID" in ascending order, and then by "OrderID".