From: Robert Klemme Date: 2005-08-05T03:11:05+09:00 Subject: Re: Cascading <=> comparisons Michael Campbell wrote: > "Robert Klemme" writes: > >> David A. Black wrote: >>> Hi -- >>> >>> On Sat, 16 Jul 2005, Robert Klemme wrote: >>> >>>> This technique can be applied to sort_by, too: >>>> >>>>>> hash.sort_by {|a| a.reverse} >>>> => [["a", 1], ["d", 1], ["c", 3], ["b", 4]] >>>> >>>> But this shows a strange anomaly - this seems like a bug in 1.8.2. >>>> >>>>>> hash.sort_by {|a| a.reverse!} >>>> => [[1, "a"], [1, "d"], [3, "c"], [4, "b"]] >>> >>> I'll probably figure this out as soon as I hit 'send'... but what's >>> the anomaly here? >> >> And, did you figure in the meantime? It's the different result - >> IMHO anything that sort_by does should have no such effect on the >> result. > > Even if the operation is a "bang" one? IMO yes. robert