Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save harukizaemon/213303 to your computer and use it in GitHub Desktop.

Select an option

Save harukizaemon/213303 to your computer and use it in GitHub Desktop.
From 3fb224e93db9fbd3c0964de6e5ee4e7319bfc9d8 Mon Sep 17 00:00:00 2001
From: Simon Harris <[email protected]>
Date: Mon, 19 Oct 2009 22:17:51 +1100
Subject: [PATCH] Implemented: Array#sort raises an error if objects can't be compared
---
kernel/common/array.rb | 2 +-
spec/tags/frozen/core/array/sort_tags.txt | 1 -
2 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/kernel/common/array.rb b/kernel/common/array.rb
index e022c4a..3669fc4 100644
--- a/kernel/common/array.rb
+++ b/kernel/common/array.rb
@@ -1689,7 +1689,7 @@ class Array
while i <= right
j = i
- while j > @start and (@tuple.at(j - 1) <=> @tuple.at(j)) > 0
+ while j > @start and Type.coerce_to_comparison(@tuple.at(j - 1), @tuple.at(j)) > 0
@tuple.swap(j, (j - 1))
j -= 1
end
diff --git a/spec/tags/frozen/core/array/sort_tags.txt b/spec/tags/frozen/core/array/sort_tags.txt
index c6ca567..3222bb3 100644
--- a/spec/tags/frozen/core/array/sort_tags.txt
+++ b/spec/tags/frozen/core/array/sort_tags.txt
@@ -1,3 +1,2 @@
fails:Array#sort! temporarily freezes self and recovers after sorted
fails:Array#sort! raises a TypeError on a frozen array
-fails:Array#sort raises an error if objects can't be compared
--
1.6.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment