http://qs321.pair.com?node_id=146105


in reply to (Golf) Keysort

Here's my lexicographic solution, which comes in at 89 characters (including the call to sort):
sub chipmunk_lexi { sort{(($B)=$b=~($r='^\s*(0|-?[1-9]\d{0,8})(?!\d)'))<=>(($A)=$a=~$r)||$ +A<=>$B||$a cmp$b}@_ }
If I've understood the hole properly, the definitions of "integer" and "starting with an integer" are a bit tricky. '0' is an integer, but '00' isn't; '0a' starts with an integer, but '00a' doesn't. Thus, '0', '1', '00', 'adam' would be sorted in that order. Have I got that right?