@@ -3455,44 +3455,33 @@ rb_ary_sort_bang(VALUE ary)
3455
3455
3456
3456
/*
3457
3457
* call-seq:
3458
- * array. sort -> new_array
3459
- * array. sort {|a, b| ... } -> new_array
3458
+ * sort -> new_array
3459
+ * sort {|a, b| ... } -> new_array
3460
3460
*
3461
- * Returns a new +Array+ whose elements are those from +self+, sorted.
3461
+ * Returns a new array containing the elements of +self+, sorted.
3462
3462
*
3463
- * With no block, compares elements using operator <tt>#<=></tt>
3464
- * (see Comparable ):
3463
+ * With no block given , compares elements using operator <tt>#<=></tt>
3464
+ * (see Object#<=> ):
3465
3465
*
3466
- * a = 'abcde'.split('').shuffle
3467
- * a # => ["e", "b", "d", "a", "c"]
3468
- * a1 = a.sort
3469
- * a1 # => ["a", "b", "c", "d", "e"]
3466
+ * [0, 2, 3, 1].sort # => [0, 1, 2, 3]
3470
3467
*
3471
- * With a block, calls the block with each element pair ;
3472
- * for each element pair +a+ and +b+, the block should return an integer :
3468
+ * With a block given , calls the block with each combination of pairs of elements from +self+ ;
3469
+ * for each pair +a+ and +b+, the block should return a numeric :
3473
3470
*
3474
3471
* - Negative when +b+ is to follow +a+.
3475
3472
* - Zero when +a+ and +b+ are equivalent.
3476
3473
* - Positive when +a+ is to follow +b+.
3477
3474
*
3478
3475
* Example:
3479
3476
*
3480
- * a = 'abcde'.split('').shuffle
3481
- * a # => ["e", "b", "d", "a", "c"]
3482
- * a1 = a.sort {|a, b| a <=> b }
3483
- * a1 # => ["a", "b", "c", "d", "e"]
3484
- * a2 = a.sort {|a, b| b <=> a }
3485
- * a2 # => ["e", "d", "c", "b", "a"]
3477
+ * a = [3, 2, 0, 1]
3478
+ * a.sort {|a, b| a <=> b } # => [0, 1, 2, 3]
3479
+ * a.sort {|a, b| b <=> a } # => [3, 2, 1, 0]
3486
3480
*
3487
3481
* When the block returns zero, the order for +a+ and +b+ is indeterminate,
3488
- * and may be unstable:
3489
- *
3490
- * a = 'abcde'.split('').shuffle
3491
- * a # => ["e", "b", "d", "a", "c"]
3492
- * a1 = a.sort {|a, b| 0 }
3493
- * a1 # => ["c", "e", "b", "d", "a"]
3482
+ * and may be unstable.
3494
3483
*
3495
- * Related: Enumerable#sort_by .
3484
+ * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching] .
3496
3485
*/
3497
3486
3498
3487
VALUE
0 commit comments