in reply to Golf: Arbitrary Alphabetical Sorting
96 characters.
BTW, although %k is not lexicalized to the sub, I don't think it matters, since any leftover contents which are not overwritten won't be used. (Also assume that no other characters are present in the words.)sub o { @k{@$A}=map chr,1..@{$A=$_[0]}; map{s/.*\0//s;$_}sort map{($x=$_)=~s/./$k{$&}/gs;"$x\0$_"}@{+pop} }
Update: I added /s to both substitutions, to avoid problems with \n. Thanks tilly!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: Golf: Arbitrary Alphabetical Sorting
by tilly (Archbishop) on May 09, 2001 at 21:36 UTC |