From: Christer Nilsson Date: 2005-12-13T21:09:31+09:00 Subject: Re: stable sort_by? Or using Array instead of Hash: I don't think sort is stable. You have to specify the sorting criteria, and sort only once. require 'test/unit' class TestSortBy < Test::Unit::TestCase def test_all a= [["A", 3, 2, 6, 114], ["B", 0,-2, 4, 112], ["C", 3, 4, 4, 110], ["D", 3, 4, 4, 108]] assert_equal [["A", 3, 2, 6, 114], ["C", 3, 4, 4, 110], ["D", 3, 4, 4, 108], ["B", 0, -2, 4, 112]], a.sort_by {|name,x,y,z,w| [x, w] }.reverse end end Christer -- Posted via http://www.ruby-forum.com/.