Sort - Syntax & Usage | AutoHotkey
https://autohotkey.com/docs/commands/Sort.htm
- Here is an example showing that a`t and a are sorted incorrectly when the delimiter is `r`n.If this option is not present, x defaults to linefeed (`n), which correctly sorts VarName if its lines end in either LF (`n) or CR+LF (`r`n).
Code: Select all
q:: ;test Sort command's handling of LFs/CRLFs
vText := "a`t_a"
;vText := "a_a`t"
vTextLF := StrReplace(vText, "_", "`n")
vTextCRLF := StrReplace(vText, "_", "`r`n")
Sort, vTextLF
Sort, vTextCRLF
vTextLF := StrReplace(vTextLF, "`t", "[TAB]") ;sorted correctly
vTextCRLF := StrReplace(vTextCRLF, "`t", "[TAB]") ;sorted incorrectly
MsgBox, % vTextLF "`r`n`r`n" vTextCRLF
return
- An OmitChars parameter or functionality might be useful in any potential AHK v2 update to the Sort function, cf. StrSplit and Loop-Parse.
- A workaround is to replace CRLFs with LFs, sort, and then replace LFs with CRLFs.