Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re (tilly) 3: Golf: Arbitrary Alphabetical Sorting

by tadman (Prior)
on May 10, 2001 at 01:39 UTC ( #79264=note: print w/ replies, xml ) Need Help??


in reply to Re (tilly) 3: Golf: Arbitrary Alphabetical Sorting
in thread Golf: Arbitrary Alphabetical Sorting

You can save a single character by using a glob, such as:

sub o { ($l,*w,$")=@_;sub g{$_=pop;s/./chr index"@$l",$&/ges;$_}sort{g($a)cmp +g+$b}@w }
So *w ... @w instead of $w ... @$w.

'1e9' or 'chr' vary only in that '1e9' would support an alphabet of length > 255, but if you're using UNICODE, then chr would likely return two characters anyway.


Comment on Re: Re (tilly) 3: Golf: Arbitrary Alphabetical Sorting
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-04 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls