The function SortStringList sorts the strings contained in the string list SL according to the specified criteria. SortStringList is much more powerful than the common Sort method of the class TStringList (which always sorts the strings as they are, beginning with the first character of each string).
The principle of the sorting implemented in SortStringList is as follows: you specify a trigger string (one or more characters) which is searched for in each string of the string list. The search can either be forward (from left to right) or backward (from right to left). If a trigger string is found, the last character of the trigger string is the anchor position which can be offset by a certain number of characters. All characters from this offset position to the right are used to sort the strings.
The parameter Trigger specifies the trigger string which is searched for in the strings. The direction of the search is contriolled by the sign of the parameter TrgCnt (see figure below), the value of TrgCnt specifies the n-th occurence of the trigger string. The parameter Sortpos defines the offset from the anchor of the trigger string.
If IgnoreCase is TRUE the comparison of the strings is not case-sensitive. The flag SortByNumValue controls whether the sorting is performed using a strict alphanumeric comparison (SortByNumValue = FALSE) or whether the characters at the sorting position are interpreted as numeric values. Please note that the numeric interpretation always expects integer numbers, floating point numbers might result in unexpected sort orders.
The function returns the following error codes:
0 ... everything is OK, the string list is sorted
-1 ... Trigger cannot be found TrgCnt times in at least one of the strings
-2 ... SortPosition was out of range in at least one of the strings
-3 ... TrgCnt must not be zero