Skip to content

Commit

Permalink
[Truffle] Adding Array#sort_by! to array.rb.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjfish committed Mar 20, 2015
1 parent 363daa7 commit 418dab9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/array/sort_by_tags.txt
@@ -1,7 +1,2 @@
fails:Array#sort_by! sorts array in place by passing each element to the given block
fails:Array#sort_by! returns an Enumerator if not given a block
fails:Array#sort_by! completes when supplied a block that always returns the same result
fails:Array#sort_by! raises a RuntimeError on a frozen array
fails:Array#sort_by! raises a RuntimeError on an empty frozen array
fails:Array#sort_by! returns the specified value when it would break in the given block
fails:Array#sort_by! makes some modification even if finished sorting when it would break in the given block
8 changes: 8 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/array.rb
Expand Up @@ -1080,6 +1080,14 @@ def transpose
out
end

def sort_by!(&block)
Rubinius.check_frozen

return to_enum :sort_by! unless block_given?

replace sort_by(&block)
end

# Insertion sort in-place between the given indexes.
def isort!(left, right)
i = left + 1
Expand Down

0 comments on commit 418dab9

Please sign in to comment.