minor bug: Sort command's handling of LFs/CRLFs

Report problems with documented functionality
User avatar
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

minor bug: Sort command's handling of LFs/CRLFs

15 Nov 2018, 09:28

- This statement is not quite correct:
Sort - Syntax & Usage | AutoHotkey
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).
- Here is an example showing that a`t and a are sorted incorrectly when the delimiter is `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
- Personally I would be fine if the documentation was amended with a warning, if this bug was too complicated/minor to fix.
- 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.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 4 guests