Golf the Pigeonhole sort
Ruby, 43

def s a,*b,&amp;f
a.map{|x|b[f[x]]=x}
b-[p]
end


Calling looks like

p s(["a","ccc","bb","eeeee"],&amp;:length)
  -&gt; ["a", "bb", "ccc", "eeeee"]


Tricks: *b in the arg list creates an empty output array (so long as you don't, y'know, pass any args). &amp;f creates a lambda reference to the passed-in block that can be called via f[] (normal Ruby convention is to use yield). a.map iterates over the input array without modifying it and is one character shorter than a.each. b-[p] strips out the nil values, equivalent to b.compact.