Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Sort::Naturally for more general use' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Sort::Naturally for more general use
Authored by: schwern on Jul 28, '03 08:41:59PM

Using sort is ok as long as you know before hand what your files are going to look like. For general use, you need something a bit more intellegent. Something that knows how to identify a number and sort them naturally. The Sort::Naturally Perl module can do this:

~/tmp/sort $ ls
23  4  bar  foo  foo10  foo2  foo392  foobar23  foobar4
~/tmp/sort $ perl -MSort::Naturally -wle 'print join "  ", nsort @ARGV' *
4  23  bar  foo  foobar4  foobar23  foo2  foo10  foo392

[ Reply to This | # ]