sort-datatable
Alphabetically sorts the rows in a datatable
Sorts the rows in a datatable based on values in one or more columns.
TIP
: Numbers are treated as text (e.g. list order will be 1,12,2 instead of 1,2,12).
Arguments
Inputs:
data
: The datatable to be sorted.
columns
: A map of columns used for sorting. The datatable will be sorted by the 1st map item key (column name). The value should be 'asc' or 'desc'. If there is a 2nd item the dataframe will then be sorted by this.
Output:
data
: A sorted datatable.
Example
Original data
A
100
category1
B
50
category4
C
25
category2
D
200
category3
E
200
category1
F
50
category1
(Note column2 sorting results show effects of numbers sorted as text)
A
100
category1
E
200
category1
F
50
category1
C
25
category2
D
200
category3
B
50
category4
(Note column2 sorting results show effects of numbers sorted as text)
A
100
category1
E
200
category1
D
200
category3
C
25
category2
F
50
category1
B
50
category4
Possible use cases
Place high-impact rows at the top of a data set (e.g. to be easiest to find in Microreact data table)
Organize data for sharing in a report
Last updated