ABSTRACT

This chapter considers the sorting of arrays according to several criteria. It describes the alphabetization as a simple application of sorting once the character data are represented as positions in an alphabet. The chapter introduces modular arithmetic and uses it to modify the alphabetizing scheme. A Programming Language (APL) grade up function, denoted, results in a list of indices. Many versions of APL support monadic grade up on matrix arguments. Grade up applied to a matrix gives the indices of rows ordered lexicographically. Grade up and index can be used to alphabetize a list of names. First dyadic iota is used to get a matrix of numbers from a matrix of letters. Grade up is then applied to the numeric matrix. Dyadic iota yields interesting information when both arguments are the same vector. The APL primitive function represent or encode is used to change numbers into alternate, possibly nonuniform, base representations.