Project

General

Profile

Actions

Bug #252

closed

Array#sort doesn't respect overridden <=>

Added by zenspider (Ryan Davis) almost 16 years ago. Updated almost 13 years ago.

Status:
Closed
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

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0