From: w_a_x_man Date: 2010-11-08T03:20:13+09:00 Subject: Re: sort_by is not stable ? On Nov 7, 4:22 am, Michel Demazure wrote: > sort_by  is not a stable sorting method (ruby 1.9.2 p0) > > I am doing word statistics in a text file. I have a long array of > entries [word, number], sorted by alphabetic order on word. When I sort > on number, entries with the same number are shuffled. > I've noticed that it's unstable under 1.8.7: %w(foo bar car war raw rat cat or bat is).sort. sort_by{|s| s.size} ==>["is", "or", "bar", "cat", "foo", "car", "bat", "rat", "raw", "war"] VERSION ==>"1.8.7"