Project

General

Profile

Actions

Bug #252

closed

Array#sort doesn't respect overridden <=>

Added by zenspider (Ryan Davis) about 14 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
Backport:
[ruby-core:17708]

Description

=begin
We had this issue reported against rubinius. We're not sure whether it is a bug or a feature in MRI.

class String
def <=>(other)
self.length <=> other.length
end
end

junk = %w[these words should be sorted in the order of their length]
puts junk.sort

MRI (1.8, 1.9) does not respect new behavior of <=>.

Bug or feature?
=end

Actions

Also available in: Atom PDF