You are here: start » ppl » statements » sort

SORT sortArry, pointerArray

SORT sortArry, pointerArray

Sort the contents of an array into a pointer array.

     sortArray    = The data to sort (Any type may be used for this array)  
     pointerArray = An integer array which will be used as an array of pointers into sortArray for accessing sortArray in sorted order (This array should be of type INTEGER)  

Note that sortArray and pointerArray are restricted to one (1) dimensional arrays.
The following is an example of displaying an array in unsorted and sorted order:

     STRING  s(999) ; Remember that arrays are 0-based, so these statements  
     INTEGER p(999) ; will allocate 1000 elements each  
     ; Do something here to read data into s  
     SORT s,p  
     INTEGER i  
     FOR i = 0 TO 999 ; This loop will display in unsorted order  
       PRINTLN s(i)  
     NEXT  
     FOR i = 0 TO 999 ; This loop will display in sorted order  
       PRINTLN s(p(i))  
     NEXT  
ppl/statements/sort.txt · Last modified: 2019/04/16 14:00
CC Attribution 4.0 International Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution 4.0 International