Sort - Syntax & Usage | AutoHotkey
- 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).
- Personally I would be fine if the documentation was amended with a warning, if this bug was too complicated/minor to fix.
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.