Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: (Golf) Keysort

by japhy (Canon)
on Feb 14, 2002 at 15:13 UTC ( [id://145460]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # this is LEXICAL sorting
    #2345678901234567890123456789012345678901234567890123
    sub JAPHY {
    sort{(*-,*+)=map[/^\s*(0|-?[1-9]\d{0,8})(.*)$/],$a,$b
    ;@-?@+?$-[0]-$+[0]||$-[1]cmp$+[1]:-1:@+?1:$a cmp$b}@_
    }
    
  2. or download this
    #234567890123456789012345678901234567890123456789
    sub JAPHY {
    (*-,*+)=map[/^\s*(0|-?[1-9]\d{0,8})(.*)$/],$a,$b;
    @-?@+?$-[0]-$+[0]||$-[1]cmp$+[1]:-1:@+?1:$a cmp$b
    }
    
  3. or download this
    #2345678901234567890123456789012345678901234567890123456
    sub JAPHY {
    my($A,$B)=map[/^\s*(0|-?[1-9]\d{0,8})(.*)$/],$a,$b;
    @$A?@$B?$$A[0]-$$B[0]||$$A[1]cmp$$B[1]:-1:@$B?1:$a cmp$b
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (9)
As of 2024-04-18 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found