Commands for Sorting or Ranking

These three commands work together to enable rankings to be made with Compare. They enable rankings by levels, sums, growth rates, or averages. The \startsort command is given before the range of lines that is to be sorted, and \endsort is given after that range. Printing of those lines will be suppressed until the first \printsort command, and printing of the rest of the table should resume after \printsort. Note that for these features to work, all three commands must be in the same file. In other words, do not put \add or \fadd commands between the \startsort and \endsort

\ss <date expression> [<size to allocate>]
\startsort <date expression> [<size to allocate>]
Put the \startsort command before the lines in the stub file that you would like to sort. The date expression represents the number that you will use as the criteria for the sort. This can be a value for single year, a range of years indicating a growth rate (e.g. 1990-1997), a sum (1990+1997), or an average (1990|1997). Note that the date expression used for the sorting need not be a date expression actually used in the table, but it can be any valid date expression that makes sense for the bank that you are using. Note that if you are comparing several banks, the sorting will be based on the value of the variables for this date expression in the first simulation bank.

The last argument for \startsort is optional. By default, enough space is set up to sort up to 500 lines. If you want to save memory, you may reduce this number, or if you need more than 500 you need to increase it. Note that Compare will sort only lines that normally would print values, i.e., either variables or expressions. All other lines such as \center, \line, ;, etc. will be skipped.

Example:

\startsort 90-95 1000
\es
\endsort
The \endsort command marks the end of the range of the table that will be sorted. Note that all table lines between the \startsort and \endsort commands will not be printed until a \printsort command is given.
\ps [<direction>] [<numtoprint>]
\printsort [<direction>] [<numtoprint>]
The \printsort command is the place where the work is done. Both arguments are optional. For the first, the sort direction is ‘d’ (descending) by default. If you want the sort to be in ascending order, give an ‘a’. The second option is the number of items you would like to print.

For example, if you want to print the 10 largest items, you would use:

\printsort d 10