Skip to content

Commit c78e298

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Tweaks for Array#sort!
1 parent b1ffd9e commit c78e298

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

array.c

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,43 +3352,12 @@ sort_2(const void *ap, const void *bp, void *dummy)
33523352

33533353
/*
33543354
* call-seq:
3355-
* array.sort! -> self
3356-
* array.sort! {|a, b| ... } -> self
3355+
* sort! -> self
3356+
* sort! {|a, b| ... } -> self
33573357
*
3358-
* Returns +self+ with its elements sorted in place.
3359-
*
3360-
* With no block, compares elements using operator <tt>#<=></tt>
3361-
* (see Comparable):
3362-
*
3363-
* a = 'abcde'.split('').shuffle
3364-
* a # => ["e", "b", "d", "a", "c"]
3365-
* a.sort!
3366-
* a # => ["a", "b", "c", "d", "e"]
3367-
*
3368-
* With a block, calls the block with each element pair;
3369-
* for each element pair +a+ and +b+, the block should return an integer:
3370-
*
3371-
* - Negative when +b+ is to follow +a+.
3372-
* - Zero when +a+ and +b+ are equivalent.
3373-
* - Positive when +a+ is to follow +b+.
3374-
*
3375-
* Example:
3376-
*
3377-
* a = 'abcde'.split('').shuffle
3378-
* a # => ["e", "b", "d", "a", "c"]
3379-
* a.sort! {|a, b| a <=> b }
3380-
* a # => ["a", "b", "c", "d", "e"]
3381-
* a.sort! {|a, b| b <=> a }
3382-
* a # => ["e", "d", "c", "b", "a"]
3383-
*
3384-
* When the block returns zero, the order for +a+ and +b+ is indeterminate,
3385-
* and may be unstable:
3386-
*
3387-
* a = 'abcde'.split('').shuffle
3388-
* a # => ["e", "b", "d", "a", "c"]
3389-
* a.sort! {|a, b| 0 }
3390-
* a # => ["d", "e", "c", "a", "b"]
3358+
* Like Array#sort, but returns +self+ with its elements sorted in place.
33913359
*
3360+
* Related: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].
33923361
*/
33933362

33943363
VALUE

0 commit comments

Comments
 (0)