Table of contents
TOC
Collapse the table of content
Expand the table of content

Table.Sort

Owen Duncan|Last Updated: 4/19/2018

About

Sorts the rows in a table using a comparisonCriteria or a default ordering if one is not specified.

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

Arguments

ArgumentDescription
tableThe Table to modify.
optional comparisonCriteriaSort comparison criteria.

Remarks

  • Table.Sort is similar to List.Sort but requires a table as input.

Examples

Table.Sort(  

    Table.FromRecords(  

{  

      [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],  

      [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],  

      [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],  

      [OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],  

      [OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],  

      [OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],  

      [OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],  

      [OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],  

      [OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]  

}  

),  

        {{"CustomerID", Order.Ascending}, "OrderID"})  
OrderIDCustomerIDItemPrice
11Fishing rod100
211 lb. worms5
61Tackle box20
32Fishing net25
43Fish tazer200
53Bandaids2
75Bait3.25
85Fishing Rod100
96Bait3.25
© 2018 Microsoft