Table of Contents

5.05 Array Sort

SORT

Function:

Sorts an array.

Syntax:

SORT array [USE compare_func] 

The compare function, if specified, is passed two arguments to compare. It must make a comparison and then return one of:

return code condition
-1 x < y
+1 x > y
0 x = y

Example:

func qscmp(x, y)
  if x = y
    qscmp = 0
  else if x > y
    qscmp = 1
  else
    qscmp = -1
  end func qscmp(x, y)
...
range a(5)
for i = 0 TO 5
  a(i) = random
  next
sort a use qscmp(x,y)

lynplex/lp0505.txt · Last modified: 2012/09/08 15:08 (external edit)