dos_strsort - dalefugier/DOSLib GitHub Wiki

Sorts a list of strings.

Syntax

(dos_strsort strings [mode [ascending]])

Parameters

strings

A list of strings.

mode

The sorting mode, where:

Value Description
-1 Logical, or natural, sorting. Digits in the strings are considered as numerical content rather than text. Note, this method is not case-sensitive.
0 (Default) Case insensitive sorting.
1 Case sensitive sorting.

ascending Sort the list in either ascending (T) or descending (nil) order. If omitted, the list is sorted in ascending order.

Returns

A sorted list of strings if successful.

nil on error.

Examples

Command: (setq x '("1A" "2A" "3A" "10C" "10B" "10A" "11B" "11D"))
("1A" "2A" "3A" "10C" "10B" "10A" "11B" "11D")

Command: (dos_strsort x)
("10A" "10B" "10C" "11B" "11D" "1A" "2A" "3A")

Command: (dos_strsort x 0 nil)
("3A" "2A" "1A" "11D" "11B" "10C" "10B" "10A")

Command: (dos_strsort x -1)
("1A" "2A" "3A" "10A" "10B" "10C" "11B" "11D")

Command: (dos_strsort x -1 nil)
("11D" "11B" "10C" "10B" "10A" "3A" "2A" "1A")