Advanced tables and statistics > Other tabulation facilities > Sorting tables > Sorting at different levels
 
Sorting at different levels
Tables may be sorted at different levels: rows may be grouped together and sorted internally within the group before the group as a whole is sorted with the other elements of the axis. This is extremely useful when you are sorting tables containing nets.
All rows in a net may be sorted amongst themselves, completely separately from the rows of any other net. Then the nets may be sorted according to the number of people in each net. The resulting table show the largest net first and within that, the most frequently occurring response.
There are two ways of sorting nets:
1 Put the keyword netsort on the a or l statement. This sorts nets and their component elements automatically, and indents each net and standard element text by a fixed amount according to the level at which the text occurs.
See Sorting with netsort.
2 Define the elements to be sorted as a group using the keywords subsort and endsort to mark the start and end of each sort group. You might find this method useful if you want to indent element texts by different amounts for each net level or sort group.
See Sorting with subsort and endsort.
See also
Sorting tables