case sensitive as the name stated, differentiate between upper case and lower case. For AM, the case sensitive option is affected by the natural sort.
Case sensitive + natural = lower case first
Case sensitive + lexical = Upper case first
While natural (natural true) means the human nature of understanding number. Multiple numbers will be grouped together to be sorted. When natural is changed to false, means it is lexical order, the machine way of understanding number. It takes 1 digit by 1 digit, it compare up to the ASCII code. The reason why case sensitive when used with lexical give upper case first, because ASCII code of 'A' is 65 (hex 41) and 'a' is 97 (hex 61). So upper case has lower number, appear first.
This is natural for human
Code: Select all
a1.txt
a2.txt
a3.txt
a4.txt
a5.txt
a6.txt
a7.txt
a8.txt
a9.txt
a10.txt
a11.txt
a12.txt
a100.txt
a101.txt
While this is natural to machine (lexical)
Code: Select all
a1.txt
a10.txt
a100.txt
a101.txt
a11.txt
a12.txt
a2.txt
a3.txt
a4.txt
a5.txt
a6.txt
a7.txt
a8.txt
a9.txt
To test it, here is the code. Use debug dialog or message dialog with {show} to check.
Code: Select all
list = newList(
"Image 42",
"image 7",
"Image 9",
"image 069",
"Image 345",
"Image 0789");
a = sort(copyList(list)); //default is case insensitive, natural
b = sort(copyList(list), true, true); //case sensitive, natural
c = sort(copyList(list), true, false); //case sensitive, lexical
d = sort(copyList(list), false, true); //case insensitive, natural
e = sort(copyList(list), false, false); //case insensitive, lexical
show = "a. Default : Case Insensitive, Natural\n{a,listformat}\n\n" +
"b. true, true : Case Sensitive, Natural\n{b,listformat}\n\n" +
"c. true, false : Case Sensitive, Lexical\n{c,listformat}\n\n" +
"d. false, true : Case Insensitive, Natural\n{d,listformat}\n\n" +
"e. false, false : Case Insensitive, Lexical\n{e,listformat}\n\n";
- As you can see, a and d has the same result. Means, omitting the option, sort(list), will default to false, true //case insensitive, natural
- in "b. true, true : Case Sensitive, Natural", lower case "image" will get the first place. Then, between 7 and 069, since it is natural sort, 7 < 69, so 7 come first. The same with the "Image", 9 < 42, so 9 come first
- in "c. true, false : Case Sensitive, Lexical", because lexical means ASCII code, "Image" will come first. The 0789 and 345, the first digit of 0789 is 0, while 345 is 3. That's why 0 come first, hence 0789 is above 345. The same with 069 vs 7, first digit 0 vs 7, 069 is above.
- d is the default option we want to use most of the time, case insensitive and natural
- in "e. false, false : Case Insensitive, Lexical", since it is not case sensitive, the only thing matters is the number. Number with first digit 0 will come first. hence 069 and 0789. 7 and 9 despite being the lowest number, come last.
In most cases, you want to use
"d. false, true : Case Insensitive, Natural", which is already the default option.