table sort rows, table sort selected rows
This function sorts the row according to sorting criteria defined, i.e. columns and applicable sorting options. The function table sort selected rows will only sort the applicable rows, but leave all remaining rows untouched, i.e. in their original locations.
Indirect parameter passing is disabled
This function provides a table context for partial table specifications with table name and row number for selected function parameters
2-4
No. | Type | Description |
---|---|---|
1. input |
string | Name of existing table |
Opt. 2. code |
expression :string |
Expression to select rows Applicable to table sort selected rows only: |
2 / 3. input |
table columns | Columns considered for sorting order If more than 1 column is specified, then the first column has the highest sorting priority, with additional columns considered
if the prior comparison resulted in equal contents, e.g. sorting by last name followed by first name.
|
Opt. 3 / 4 input |
string | Sorting option See sorting options for available values. Default value: alphabetic |
table initialize( animals,
{ { Animal, Leg Count },
{ ant, 6 }, { mouse, 4 }, { spider, 4 }, { octopus, 8 }, { bird, 2 },
{ tick, 8 }, { orang utan, 2 or 4 }, { human, 2 }, { lobster, 8 }, { snake, 0 },
{ cat, 4 }, { kangaroo, 2 or 4 }, { spider, 6 }, { fly, 6 }, { worm, 0 } } );
echo("Sort animals. Spiders are sorted by leg count.");
table copy table ( animals, a );
table sort rows( a, { Animal, Leg Count }, { alphabetic, numeric down } );
table list( a );
echo("Sort animals with 4 legs");
table rearrange selected rows( animals, ([Leg Count]='*4*'), top );
table sort selected rows( animals, ([Leg Count]='*4*'), Animal );
table list ( animals );
Sort animals. Spiders are sorted by leg count.
0 : Animal | Leg Count
1 : ant | 6
2 : bird | 2
3 : cat | 4
4 : fly | 6
5 : human | 2
6 : kangaroo | 2 or 4
7 : lobster | 8
8 : mouse | 4
9 : octopus | 8
10 : orang utan | 2 or 4
11 : snake | 0
12 : spider | 6
13 : spider | 4
14 : tick | 8
15 : worm | 0
Sort animals with 4 legs
0 : Animal | Leg Count
1 : cat | 4
2 : kangaroo | 2 or 4
3 : mouse | 4
4 : orang utan | 2 or 4
5 : spider | 4
6 : ant | 6
7 : octopus | 8
8 : bird | 2
9 : tick | 8
10 : human | 2
11 : lobster | 8
12 : snake | 0
13 : spider | 6
14 : fly | 6
15 : worm | 0