Created
January 30, 2013 13:22
-
-
Save TLMcode/4673275 to your computer and use it in GitHub Desktop.
Sorts a list of items by alpha and ignores non word characters.
Function posted with example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;___________________ | |
; example | |
List = | |
( | |
New, Agnes | |
New Jersey | |
New, Thomas | |
New York | |
"New York Dining" | |
New York (NY) | |
New York: Visitor’s Guide | |
Newark (NJ) | |
TYPE-ADF command | |
type font | |
type foundry | |
type metal | |
Type/Specs Inc. | |
typeface | |
typeset | |
) | |
Msgbox % AlphaSortEx(List,"`n") ; <- AlphaSortEx(var containing items, delimiter) | |
;___________________ | |
; function | |
AlphaSortEx(l,del){ | |
n:=RegExReplace(l,"[^\w" del "]") | |
Sort, n | |
Loop, Parse, l, % (del,p:=1) | |
p:=RegExMatch(l,"(.*?)" del,_,StrLen(_)+p),itm:=RegExReplace(A_LoopField,"\W+") | |
,n:=RegExReplace(n,"\b" itm "\b",_1?_1:itm) | |
Return n | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment