It takes a list of numbers and a decimal precision that is used to convert them to strings. This must be done when sorting string representations of numeric data, as the decimal point in each element must be aligned at the same character position in each string. As our applications become more sophisticated, the need to efficiently deal with complex or composite data types becomes more important. In fact, the need to sort complex data collections can be more common than the need to sort lists of simple types. One way to perform these more complex sorting operations would be to drop down to ADS, but if your application needs to run on different platforms or operating environments, this might not be feasible.
Listing shows a simple example of table data that is stored as a list of lists.
This list might represent the inventory of a fruit stand, where the first column is a type of fruit, the second column is the quantity of the item in stock, the third column is the variety or brand name, and the forth column is the item cost per unit of stock. Too understand this process better we must break it down into discrete steps. We'll accomplish this by first generating a separate list containing the string representation of the sort expression and an integer that represents the position of the element in the original input list that produced the sort expression, and we'll then sort that list to compute the sorted order of the original input list. This function is included in listing 1 as a convenience to simplify your own experiments with this and other code. One important point here, is that the width of the right-justified string must be of sufficient length to hold the sort expression.