Skip to content

Commit 418dab9

Browse files
committed
[Truffle] Adding Array#sort_by! to array.rb.
1 parent 363daa7 commit 418dab9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
fails:Array#sort_by! sorts array in place by passing each element to the given block
2-
fails:Array#sort_by! returns an Enumerator if not given a block
3-
fails:Array#sort_by! completes when supplied a block that always returns the same result
4-
fails:Array#sort_by! raises a RuntimeError on a frozen array
5-
fails:Array#sort_by! raises a RuntimeError on an empty frozen array
61
fails:Array#sort_by! returns the specified value when it would break in the given block
72
fails:Array#sort_by! makes some modification even if finished sorting when it would break in the given block

truffle/src/main/ruby/core/rubinius/common/array.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,14 @@ def transpose
10801080
out
10811081
end
10821082

1083+
def sort_by!(&block)
1084+
Rubinius.check_frozen
1085+
1086+
return to_enum :sort_by! unless block_given?
1087+
1088+
replace sort_by(&block)
1089+
end
1090+
10831091
# Insertion sort in-place between the given indexes.
10841092
def isort!(left, right)
10851093
i = left + 1

0 commit comments

Comments
 (0)