method
sort_by!
ruby latest stable - Class:
Array
sort_by!()public
Sorts self in place using a set of keys generated by mapping the values in self through the given block.
The result is not guaranteed to be stable. When two keys are equal, the order of the corresponding elements is unpredictable.
If no block is given, an Enumerator is returned instead.
See also Enumerable#sort_by.
static VALUE
rb_ary_sort_by_bang(VALUE ary)
{
VALUE sorted;
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
rb_ary_modify(ary);
sorted = rb_block_call(ary, rb_intern("sort_by"), 0, 0, sort_by_i, 0);
rb_ary_replace(ary, sorted);
return ary;
}