SortArrayLinked

Prev Next Home Home Table Of Contents Index

SortArrayLinked (Array,KeyArray)

SortArrayLinked will sort an array based upon the contents of a key array.


Example:
var NumberArray,key

writeln "Array sequential on element 1"

loop 10 NumberArray[LoopIndex,1]=LoopIndex NumberArray[LoopIndex,2]=(random mod 50 + 1) writeln NumberArray[LoopIndex,1] " " NumberArray[LoopIndex,2] endloop ;the above creates a 2-dimensional array called NumberArray, ;where the first element is an array 1 through 10 and the ;second element is a set of random numbers

MatrixInvert NumberArray ;the coordinates of the 2-dimensional array are reversed

key = NumberArray[2] matrixinvert NumberArray ;the array is reinverted

SortArrayLinked NumberArray,key ;the array is sorted by key ;the array is now in order by the second element

writeln "Array now sorted based on element 2"

loop 10 writeln NumberArray[LoopIndex,1] " " NumberArray[LoopIndex,2] endloop

See Also: MatrixInvert SortArray

Category: Array

Prev Next Home Home Table Of Contents Index

Sponsors
Shopping
Forum
Forum
email
EMail
Index
Index
Home
Home