Versions Compared

Key

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

...

Code Block
NewArray = SRP_Sort_Array(Array, SortInfo, IsList, 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. See Remarks for details.
IsListSetting this to 1 Indicates that the Array parameter is in LIST format. Setting it to 0 indicates that it is in ARRAY format. Optional. If you omit this parameter, 0 (ARRAY format) will be assumed.
MajorDelimThe delimiter that separates rows if Array is in LIST format or columns if it is in ARRAY format. Optional. If you omit this parameter, @FM will be assumed.
MinorDelimThe delimiter that separates elements in within each column (ARRAY format) or row (LIST format). Optional. If you omit this parameter, @VM will be assumed.
CaseSensitiveDetermines if the sort is done case sensitively (1) or insensitively (0). Optional. If you omit this parameter, the sort will be case sensitive.

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. SRP_Sort_Array is much easier to use in three waysgives you standardized sorting and ease of use:

  • Most OI programmers are familiar with the LIST and ARRAY properties of the OI Edit Table.

...

  • SRP_Sort_Array can sort using either format, whereas V119 requires your data to be in a LIST format.
  • V119 requires specific delimiters. SRP_Sort_Array lets you specify your data’s delimiters.
  • V119 often requires you to reorder your data since it always sorts starting at the first column. SRP_Sort_Array lets you specify the order in which columns are sorted.

SRP_Sort_Array is fast. Though it is not technically as fast as a V119 sort by itself, it is many times faster in situations in which you must reorganize your data before and after a V119 sort. So, if your data is already delimited by @RM and @FM; is already appended with an extra @RM; is in LIST format; and you want to sort starting from the first column – then V119 is for you. If however, you usually sort data pulled from an OpenInsight Edit Table or table record, then SRP_Sort_Array will provide a significant increase in performance and simplicity.

...

The most important component of SRP_Sort_Array 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 routine service will not know which column to sort.

...