sorting an array based on two attributes of objects

[ ['d',100], ['c',200], ['b',50], ['a',100] ].sort_by {|ns| [ - ns.last, ns.first ]} => [["b", 50], ["a", 100], ["d", 100], ["c", 200]]

An array compares on its elements. (The only change from my earlier response is to negate the salary for sorting purposes.)

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com