In message <852568F6.00397234.00 / d54mta03.raleigh.ibm.com>
schneik / us.ibm.com writes:

> which isn't what I normally want, I would like to do this:
> 
>     # ruby -e 'print ["computer ","Boston ", "Austin ", "another
> "].dict_sort, "\n"'
>    another Austin Boston computer

Well, below is not sufficient?

# filter is deprecated on 1.5.x.  use collect! instead.

    > ruby -e 'puts  ["computer ","Boston ", "Austin ", "another "].\
    filter {|e| [e.downcase, e]}.sort.filter {|k, e| e}'
    another 
    Austin 
    Boston 
    computer 


This `Schwartzian Transform' method is famous in Perl community.  A
good name is presented, this may be introduced to ruby standard
library :-)

    class Array
      def sort_with_key
        # to preserve original array, first filter is replaced with collect.
        collect { |e| [yield(e), e] }.sort.filter { |k, e| e }
      end
    end


-- 
kjana / os.xaxon.ne.jp                                   June 6, 2000
The more haste, the less speed.