Project

General

Profile

Actions

Feature #1084

closed

request for: Array#sort_by!

Feature #1084: request for: Array#sort_by!

Added by radarek (Radosław Bułat) over 16 years ago. Updated over 14 years ago.

Status:
Closed
Target version:
-
[ruby-core:21709]

Description

=begin
$ ruby1.9.1 -e "p Array.instance_methods.grep /sort/"
[:sort, :sort!, :sort_by]

sort and sort! override it's version from Enumerable and sort_by is directly from Enumerable, but for symmetry and consistency it would be nice to have destructive sort_by! for Array.

For example:
a = [1,2,3]
a.sort_by! {|e| -e }
p a #=> [3, 2, 1]
=end

Actions

Also available in: PDF Atom