From: Robert Klemme Date: 2010-11-08T00:10:13+09:00 Subject: Re: sort_by is not stable ? On 07.11.2010 15:10, Phillip Gawlowski wrote: > On Sun, Nov 7, 2010 at 2:08 PM, Michel Demazure wrote: >> Phillip Gawlowski wrote in post #959912: >> @Phillip : I am not sure I agree. When sorting on the second half, the >> couple (["a", 3], ["b", 3]) falls under the "equal" case of the choice. > > "a" != "b" results in true, thus the couplet is *not* equal. No, Michael is right. Every sorting algorithm only ever looks at *sort keys*. So since our sort key is the second array member (the number) both mentioned records are equivalent. If you include the other field a stable sort isn't really interesting here since then all fields are part of the sort key - stable and instable algorithms will return the same then. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/