From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Sorts one or more additional arrays in the same order as the base array. The sort is in ascending order.
|array||The array to be sorted.|
|array1||The array to be sorted in the order determined by sorting the base array.
Array1 must have the same number of elements as the base array but can be of another data type. If the number of elements does not match, an OutOfBoundsException is thrown.
|array2...arrayN||Optional. Additional arrays to be sorted with the base array.
These arrays must also have the same number of elements as the base array but can be of different data types.
The base array used with the Sortwith method works with Integer, string, single, and double arrays only. It accepts only one-dimensional arrays and it should have non-unique values.Results are undefined when the elements of the base array are not unique, i.e., elements of the base array are all of the same integer value.
Sortwith is ideal for sorting all the columns of a data table by one of its columns. For example, if you have a set of three arrays that store Names, Addresses, and Phone numbers of a group of people, you can sort the data table by Name by specifying the Names array as the base array and pass the Address and Phone number arrays as the parameters.
This example sorts the columns of the data table by the values in the aNames array.
aAddresses=array("34 Pickwick","3424 Kenwood","432 Marlboro","1 Hardrock")
//display the sorted arrays in a Listbox to verify the sort