Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: sorting number

by Marshall (Canon)
on Apr 10, 2019 at 03:23 UTC ( [id://1232378]=note: print w/replies, xml ) Need Help??


in reply to sorting number

It would help the Monks greatly if the spec was more clear.
# I want to print CORE1 CORE12 CORE233 CORE8 COREA11 COREA12 COREA115
An alpha sort order will get 1,12,233,8 for CORE
A numeric sort order will get 11,12,115 for COREA
But a single general sort routine cannot do both.
At a minimum you have to specify more rules about how to reach your desired output.

There are many ways to code sorts in Perl. Some of them are quite clever and faster for large sorts versus a more straightforward approach. I personally start thinking about these fancy things when the array is >1,000 or in situations where the code is going to be run very often, by that I mean more than once per second.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232378]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-24 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found