|Liberty BASIC Help Online
SORT arrayName(), start, end, [column]
This command sorts both double and single dimensioned arrays. The start parameter specifies the element with which to begin the sort and the end parameter specifies the element where sorting should stop. Arrays can be sorted in part or in whole, and with double dimensioned arrays, the specific column to sort by can be declared. When this option is used, all the rows are sorted against each other according to the items in the specified column.
Here is the syntax for the sort command:
sort arrayName$(), i, j, [,n]
This sorts the array named arrayName$( starting with element i, and ending with element j. If it is a double dimensioned array then the column parameter tells which nth element to use as a sort key. Each WHOLE row moves with its corresponding key as it moves during the sort. If you have a double dimensioned array holding sales rep activity:
It can be holding data, one record per x position, and the record keys are in y. So for example:
repActivity$(1,1) = "Tom Maloney" : repActivity(1,2) = "01-09-93"
repActivity$(2,1) = "Mary Burns" : repActivity(2,2) = "01-10-93"
repActivity$(100,1) = "Ed Dole" : repActivity(100,2) = "01-08-93"
To sort the whole 100 items by the date field this is how the command would look:
sort repActivity$(), 1, 100, 2
To sort by name instead, then change the 2 to a 1, like this:
sort repActivity$(), 1, 100, 1
Reverse the order of the sort by reversing the order of the range of rows to sort.
'sort from row 1 to 50
sort array$(), 1, 50
'sort reversed from row 1 to 50
sort array$(), 50, 1
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/