Method: Array#sort

Defined in:
array.c

#sortArray #sort {|a, b| ... } ⇒ Array

Returns a new array created by sorting self. Comparisons for the sort will be done using the <=> operator or using an optional code block. The block implements a comparison between a and b, returning -1, 0, or +1. See also Enumerable#sort_by.

a = [ "d", "a", "e", "c", "b" ]
a.sort                    #=> ["a", "b", "c", "d", "e"]
a.sort {|x,y| y <=> x }   #=> ["e", "d", "c", "b", "a"]

Overloads:



1676
1677
1678
# File 'array.c', line 1676

VALUE
rb_ary_sort(ary)
VALUE ary;