Skip to content

Commit 161ea38

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Tweaks for Array#sort_by!
1 parent eb8cf1d commit 161ea38

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

array.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,28 +3556,24 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, dummy))
35563556

35573557
/*
35583558
* call-seq:
3559-
* array.sort_by! {|element| ... } -> self
3560-
* array.sort_by! -> new_enumerator
3559+
* sort_by! {|element| ... } -> self
3560+
* sort_by! -> new_enumerator
35613561
*
3562-
* Sorts the elements of +self+ in place,
3563-
* using an ordering determined by the block; returns self.
3562+
* With a block given, sorts the elements of +self+ in place;
3563+
* returns self.
35643564
*
35653565
* Calls the block with each successive element;
3566-
* sorts elements based on the values returned from the block.
3567-
*
3568-
* For duplicates returned by the block, the ordering is indeterminate, and may be unstable.
3569-
*
3570-
* This example sorts strings based on their sizes:
3566+
* sorts elements based on the values returned from the block:
35713567
*
35723568
* a = ['aaaa', 'bbb', 'cc', 'd']
35733569
* a.sort_by! {|element| element.size }
35743570
* a # => ["d", "cc", "bbb", "aaaa"]
35753571
*
3576-
* Returns a new Enumerator if no block given:
3572+
* For duplicate values returned by the block, the ordering is indeterminate, and may be unstable.
35773573
*
3578-
* a = ['aaaa', 'bbb', 'cc', 'd']
3579-
* a.sort_by! # => #<Enumerator: ["aaaa", "bbb", "cc", "d"]:sort_by!>
3574+
* With no block given, returns a new Enumerator.
35803575
*
3576+
* Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
35813577
*/
35823578

35833579
static VALUE

0 commit comments

Comments
 (0)