Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 02, 2015, 07:53:23 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Natural line sorting in file  (Read 2213 times)

TucknDar

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,096
    • View Profile
    • Read more about this member.
    • Donate to Member
IDEA: Natural line sorting in file
« 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 :)

thanks!

kfitting

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 575
    • View Profile
    • Donate to Member
Re: IDEA: Natural line sorting in file
« Reply #1 on: June 22, 2009, 03:47:41 PM »
See the following websites for more general info:
http://www.codinghor...archives/001018.html
http://www.codeproje...ralSortComparer.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

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 4,393
    • View Profile
    • Donate to Member
Re: IDEA: Natural line sorting in file
« Reply #2 on: June 23, 2009, 12:25:51 PM »
No GUI necessary, btw. command line tool would be perfect :)

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

Code: [Select]

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 132 times.)

TucknDar

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,096
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: Natural line sorting in file
« Reply #3 on: June 23, 2009, 12:35:47 PM »
Thanks, skwier, works great :)