I need to use *sort_by* to sort a table, since the user could select
columns in any order.

    b=[ ["radio", 30, 5], ["radio", 20, 5], ["archie", 20, 5],
["newton", 10, 3] ]
    b.sort_by{|x| [ x[1], x[0] ]}

Works fine. However, often the user will want a reverse sort on some
field. I do not off-hand know the datatype of the field, but in most
cases it will be a String.

I tried:

    b.sort_by{|x| [ !x[1] ]}
This works (one criteria), but this does not:
    b.sort_by{|x| [ !x[1], x[0] ]}

Another thread here, suggested using a minus for Numbers but what about
Strings.
Thx, rahul.

-- 
Posted via http://www.ruby-forum.com/.