Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
NewArray = SRP_Array("SortRows", Array, SortInfo, FormatOrientation, MajorDelim, MinorDelim, CaseSensitive)

Returns

The sorted array.

...

ParameterDescription
ArrayThe dynamic array to be sorted. (REQUIRED)
SortInfoAn @FM delimited array listing the order columns are sorted and how they are to be sorted. (REQUIRED)
FormatOrientationThe given arrays formatorientation of array: LIST or ARRAY. (OPTIONAL)
MajorDelimThe delimiter that separates rows if Array is in LIST format or columns if it is in ARRAY format. (OPTIONAL)
MinorDelimThe delimiter that separates elements in within each column (ARRAY format) or row (LIST format). (OPTIONAL)
CaseSensitiveDetermines if the sort is done case sensitively (set to 1, which is the default) or insensitively (set to 0). (OPTIONAL)

Remarks

OpenInsight provides sorting capabilities via it's V119 routine, and it is quite sufficient for the task. However, it can be cumbersome to prep your data to meet its strict requirements. The SortRows service is much easier to use in three waysSortRows gives you standardized sorting and ease of use:

  • Most OI programmers are familiar with the LIST and ARRAY properties of the OI Edit Table. This service can SortRows can sort using either formatorientation, whereas V119 requires your data to be in a LIST format.
  • V119 requires specific delimiters. This service lets SortRows lets you specify your data’s delimiters.
  • V119 often requires you to reorder your data since it always sorts starting at the first column. This service lets SortRows lets you specify the order in which columns are sorted.

...

The most important component of this service is the SortInfo parameter. This is where you specify the order in which columns are sorted, their sort directions, and their sort justifications. The SortInfo parameter is an @FM delimited list of codes. Each code uses the following format:

[A|D][L|R|N]x

[A|D] determines if the column is sorted in the ascending (A) or descending (D) direction. Ascending will be assumed if you don’t provide this part of the code. [L|R|N] determines if the column data is left aligned (L) or , right aligned (R), or converted to numbers (N) during sort. Left aligned sorting is for text sorts, and right aligned sorts are for sorting simple numbers. For this reason, you can also use ‘N’ instead of ‘R’ – ‘N’ meaning “Number.” Numerical sorts actually convert the data to numbers for a more accurate sort, but non-numerical data won't sort well in this mode. If you don’t specify any part of this code, then Left aligned sort is assumed. Lastly, the ‘x’ portion of the code is the column index you wish to sort. You cannot omit this portion of the code since the service will not know which column to sort.

...

  • If you are sorting less than 4 megabytes of data, then use either format since the difference is negligible
  • If you are sorting 4 megabytes of data or more, then do one of the following:
    • If you have more rows in your data than columns, then use the LIST format if possible
    • If you have more columns in your data than rows, then use the ARRAY format if possible

...

Orientation

The Format Orientation parameter tells the SortRows service what format the original array is in. If your 2-dimensional dynamic array is delimited by rows first, then set this parameter to "LIST". If your dynamic array is delimited by columns first, then set this parameter to "ARRAY". If omitted, "ARRAY" is assumed.

...