James Gray [2008-01-25 23:57]:
> I guess I should have said:  is it that hard to call sort { |a,b|
> b <=> a }?
am i missing something? what's wrong with sort.reverse? apart from
the fact that it's a whole lot faster ;-)

i know, this is not all too serious, but just for the fun of it...
here are the timings for M = 10, 100, 1_000, 10_000:

             user     system      total        real
block    3.940000   0.410000   4.350000 (  4.349146)
by       2.580000   0.290000   2.870000 (  3.033811)
reverse  0.260000   0.020000   0.280000 (  0.287276)

block    8.540000   0.870000   9.410000 (  9.406218)
by       2.740000   0.210000   2.950000 (  2.953615)
reverse  0.180000   0.000000   0.180000 (  0.179436)

block   13.810000   1.340000  15.150000 ( 15.176457)
by       2.880000   0.220000   3.100000 (  3.099212)
reverse  0.220000   0.010000   0.230000 (  0.234392)

block   17.820000   2.230000  20.050000 ( 20.255648)
by       3.380000   0.280000   3.660000 (  3.656010)
reverse  0.300000   0.010000   0.310000 (  0.305090)

----[ sort_bench.rb ]----
require 'benchmark'

M = ARGV.first.to_i
N = 1_000_000 / M
A = (0..M).sort_by { rand }

Benchmark.bm(7) { |x|
  x.report('block')   { N.times { A.sort { |a, b| b <=> a } } }
  x.report('by')      { N.times { A.sort_by { |a| a * -1 } } }
  x.report('reverse') { N.times { A.sort.reverse } }
}
-------------------------

cheers
jens

-- 
Jens Wille, Dipl.-Bibl. (FH)
prometheus - Das verteilte digitale Bildarchiv f?r Forschung & Lehre
Kunsthistorisches Institut der Universit?t zu K?ln
Albertus-Magnus-Platz, D-50923 K?ln
Tel.: +49 (0)221 470-6668, E-Mail: jens.wille / uni-koeln.de
http://www.prometheus-bildarchiv.de/