Skip to main content


Command Description

Sort the specified column of a datatable

Command Prototype

dtTable = Datatable.SortDataTable(dataTable,columns,bAscSort)

Parameter Description

dataTableTrueexpressionobjDatatableThe data table to be filtered
columnsTruestring""Data columns to be sorted, can be filled with strings or numbers. Sort the column named "string" if filled with strings; sort multiple columns in the array if filled with an array
bAscSortTruebooleanTrueWhether to sort in ascending order, if choose no, sort in descending order


dtTable,The variable used to save the output of the command.


aryData = [["a", 1], ["b", 2], ["c", 3], ["d", 1]] 
aryColumns = ["letter", "number"]
objDatatable = Datatable.BuildDataTable(aryData,aryColumns)
dtTable = Datatable.SortDataTable(objDatatable,"number",false)

letter number
2 c 3
1 b 2
0 a 1
3 d 1