DonationCoder.com Software > Post New Requests Here
IDEA: Natural line sorting in file
(1/1)
TucknDar:
Ok, I suppose any decent text editor should be able to sort lines based on alphabet or numbers, but I'm looking for a tool that can sort lines based on Natural order sorting, i.e.
from this:
1. some text
10. yet more text
1011. Text
2. more text again
4. more text
--- End quote ---
to:
1. some text
2. more text again
4. more text
10. yet more text
1011. Text
--- End quote ---
No GUI necessary, btw. command line tool would be perfect :)
thanks!
kfitting:
See the following websites for more general info:
http://www.codinghorror.com/blog/archives/001018.html
http://www.codeproject.com/KB/string/NaturalSortComparer.aspx
I've done an algorithm for excel using the Windows API function in XP... someone might be able to use that to simplify things.
Kevin
skwire:
No GUI necessary, btw. command line tool would be perfect :)-TucknDar (June 22, 2009, 03:23 PM)
--- End quote ---
The Unix "sort -n" command will do this easily.
--- ---
skwire@hankoku ~
$ clip
1. some text
10. yet more text
1011. Text
2. more text again
4. more text
skwire@hankoku ~
$ clip | sort -n
1. some text
2. more text again
4. more text
10. yet more text
1011. Text
skwire@hankoku ~
I've attached a Win32 binary version of the Unix sort command.
sort.zip (30.13 kB - downloaded 305 times.)
TucknDar:
Thanks, skwier, works great :)
Navigation
[0] Message Index
Go to full version