Welcome Guest.   Make a donation to an author on the site October 01, 2014, 05:26:06 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: IDEA: Natural line sorting in file  (Read 1987 times)
TucknDar
Charter Member
***
Posts: 1,094


Advanced coder of Nowt

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: June 22, 2009, 03:23:18 PM »

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:
Quote
1. some text
10. yet more text
1011. Text
2. more text again
4. more text
to:
Quote
1. some text
2. more text again
4. more text
10. yet more text
1011. Text

No GUI necessary, btw. command line tool would be perfect smiley

thanks!
Logged
kfitting
Charter Member
***
Posts: 574


View Profile Give some DonationCredits to this forum member
« Reply #1 on: June 22, 2009, 03:47:41 PM »

See the following websites for more general info:
http://www.codinghorror.c...blog/archives/001018.html
http://www.codeproject.co.../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
Logged
skwire
Moderator
*****
Posts: 4,083



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: June 23, 2009, 12:25:51 PM »

No GUI necessary, btw. command line tool would be perfect smiley

The Unix "sort -n" command will do this easily. 

[copy or print]

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 128 times.)
Logged

TucknDar
Charter Member
***
Posts: 1,094


Advanced coder of Nowt

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: June 23, 2009, 12:35:47 PM »

Thanks, skwier, works great smiley
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.027s | Server load: 0.06 ]