Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Echo Off
- Set "Usage=Echo/&Echo/%~n0 ["/F:filepath.ext" ^| "/A:Array Group Name"] & Exit /B 1"
- IF "%~1"=="" %Usage%
- IF "%~1"=="/?" %Usage%
- Set "Inset=%~1"
- Set "Switch=%Inset:~1,1%"
- Call Set "Inset=%%Inset:/%Switch%:=%%"
- Echo/%Switch%|Findstr /LIC:F > Nul && (
- (For /F "UseBackQ Delims=" %%G in (`Type "%Inset%" ^| Sort`)Do (Echo/%%~G)) 2> Nul || (Echo/Invalid Filepath:"%Inset%"&%Usage%)
- Exit /B 0
- )
- If Not "!Comspec!"=="%Comspec%" (Echo/&Echo/Usage Error - Ensure Delayed Expansion is enabled with:&Echo/Setlocal EnableDelayedExpansion& Exit /B 1)
- Echo/%Switch%|Findstr /LIC:A > Nul && (For /F "Tokens=1,2 Delims==" %%G in ('Set %Inset%')Do Echo/%%H)>"%TEMP%\__Sort.txt"
- Set "#$#=0"
- (For /F "UseBackQ Delims=" %%G in (`Type "%TEMP%\__Sort.txt" ^| Sort`)Do (
- Set "%Inset%[!#$#!]=%%~G"
- Set /A "#$#+=1"
- )
- )
- Del /Q "%TEMP%\__Sort.txt"
- Exit /B 0
- Rem ::: Sorts STRINGS alphanumericaly. Not suited to Integer strings of varying length.
- Rem ::: Can Sort text files or Arrays
- Rem ::: With the manner sort process strings, when numerical strings are sorted Single digits will be treated as a higher value than multiple digits that
- Rem ::: begin with a lesser value, as the sort is applied on the basis of character value in the string position, not the overall strings value.
- Rem ::: For a given position in a string Character sort order is: [0-9][a-z]
- Rem ::: Case is ignored
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement