From: Daniel Carrera Date: 2003-01-12T22:23:34+09:00 Subject: Spelling correction: [ was Re: sorting with the Swartzian transform] I misspelled Randal's name. It's should have been "Schwartzian transformed" as it is named after "Randal Schwartz". David, thanks for pointing that out. In my defense, I did look up his name before writing the email. The page I found with his name had it spelled wrong. Cheers, Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137 On Sun, 12 Jan 2003, WATANABE Hirofumi wrote: > Hi, > > Daniel Carrera writes: > > > This email is simply for the benefit and/or reading pleasure of ruby > > hackers. In particular those without a strong Perl background. I just > > had to do a Swartzian transform in Ruby and it occurred to me that someone > > might benefit from my experience. > > Ruby 1.8 has Enumerable#sort_by. > This method is equivalent to: > > module Enumerable > def sort_by > ary = map { |i| [yield(i), i] } > ary.sort! { |a, b| a[0] <=> b[0] } > ary.map! { |i| i[1] } > end > end > > -- > eban > >