ItemSort

Sorts a list.

Syntax:

ItemSort (list, delimiter)

Parameters:

(s) list: a string containing a list of items.

(s) delimiter: a character to act as a delimiter between items in the list.

Returns:

(s) new, sorted list.

 

This function sorts a list, using an "ANSI Collating Sequence" sort, also known as a "dictionary sort" or "word sort".  This means, among other things, that the hyphen and the apostrophe are not treated like other non alphanumeric characters. Consider the following:

lSorted1 = ItemSort("11,-1",',')
lSorted2 = ItemSort("-11,11",',') ;Secondary sort required
Message(lSorted1, lSorted2)

; Output
; lSorted1 = "-1,11"
; lSorted2 = "11,-11"

The hyphen is only considered in the string's length when a secondary sort is necessary otherwise the results are based on the length of the strings sans hyphen. The special treatment is necessary to keep hyphenated and apostrophed words next to their non punctuated equivalents in a 'word sort'.

It returns a new, sorted list; the original list is unchanged.

A single item null list ("") is not a valid list.

Example:


list=" one two three four "
newlist = ItemSort(list, " ")
Message("List generated by ItemSort", newlist)
See Also:

ArraySort, ItemCount, ItemCountCsv, ItemExtract, ItemExtractCsv, ItemInsert, ItemLocate, ItemLocateWild, ItemRemove, ItemReplace, Lists Explained