From: Martin DeMello Date: 2003-01-12T17:48:27+09:00 Subject: Re: sorting with the Swartzian transform Daniel Carrera wrote: > sorted = array.map { |obj| [ my_function(obj), obj ] }\ > .sort { |a,b| a[0] <=> b[0] }\ > .map { |arr| arr[1] } Even easier-to-use: class Array def ssort(&block) map {{|i| [&block.call(i), i]}\ .sort {|a,b| a[0] <=> b[0]}\ .map {|a| a[1]} end end martin