Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Do you know where your variables are?
 
PerlMonks  

Re: divide by '/'

by stephen (Priest)
on Apr 10, 2001 at 23:20 UTC ( [id://71543]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to divide by '/'

So, if I'm reading this right, you've got a bunch of numbers like so:
64/2829 1/349834 37823/8338 5/989328
And you want them sorted like this:
1/349834 5/989328 64/2829 37823/8338
Here:
sub sortbyfirst { my ($f_a, undef) = split(/\//, $a); my ($f_b, undef) = split(/\//, $b); return $f_a <=> $f_b; } @sorted = sort sortbyfirst @numbers;

Note: Untested.

This won't be superfast... If you've got a huge list, or this runs constantly, look into the tye transductor, illustrated here.

stephen

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://71543]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.