Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: sorting by numbers then alphabetically

by eff_i_g (Curate)
on Dec 23, 2010 at 17:18 UTC ( #878840=note: print w/replies, xml ) Need Help??


in reply to sorting by numbers then alphabetically

See Sort::Key::Natural.

Update: Or Sort::Naturally for new comparison operators.
  • Comment on Re: sorting by numbers then alphabetically

Replies are listed 'Best First'.
Re^2: sorting by numbers then alphabetically
by Anonymous Monk on Dec 23, 2010 at 17:32 UTC
    I was just looking at that but it doesn't do what i want does it...it sorts by letters then numbers doesnt it?
      Per the docs:
      Under natural sorting, strings are splitted at word and number boundaries, and the resulting substrings are compared as follows:

      * numeric substrings are compared numerically
      * alphabetic substrings are compared lexically
      * numeric substrings come always before alphabetic substrings
      I came back and looked at this thing. Looks like it would do close to what you want. From your problem description, my understanding is that you have just either numeric or alphabetic strings - so doesn't appear that there would be any substring splitting. However the "non-module" sort function as I show below is easy to write and also incorporates the case insensitive feature.
      Under natural sorting, strings are splitted at word and number boundaries, and the resulting substrings are compared as follows: * numeric substrings are compared numerically * alphabetic substrings are compared lexically * numeric substrings come always before alphabetic substrings

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://878840]
help
Chatterbox?
SuicideJunkie replaces stale cookies with fresh on the platter on the sideboard.
[SuicideJunkie]: So, possibly interesting thing; I had that script which was using more than all the ram to open an absurdly large spreadsheet. I set it up to spin overnight nightly, so it stopped releasing memory since it was never fully exited.
[SuicideJunkie]: Didn't expect that to be a problem. There's plenty of disk space for swap, and the memory space would be reused the next day. But apparently virtualbox dies with a guru meditation when there's no physical memory unused on start.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-04-26 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (491 votes). Check out past polls.