1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

documentation for sort methods

* array.c: [DOC] fix grammar in Array#sort, #sort!, #sort_by!,
  move references below the code example, add a missing reference.
* enum.c: [DOC] fix grammar in Enumerable#sort, #sort_by.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
stomar 2017-03-04 13:13:50 +00:00
parent 453199c4b6
commit b4baeb5af6
2 changed files with 10 additions and 9 deletions

15
array.c
View file

@ -2442,14 +2442,14 @@ sort_2(const void *ap, const void *bp, void *dummy)
* an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ * an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+
* are equivalent, or an integer greater than 0 when +a+ follows +b+. * are equivalent, or an integer greater than 0 when +a+ follows +b+.
* *
* The result is not guaranteed as stable. When comparison of two * The result is not guaranteed to be stable. When the comparison of two
* elements returns +0+, the order of the elements is unpredictable. * elements returns +0+, the order of the elements is unpredictable.
* *
* See also Enumerable#sort_by.
*
* a = [ "d", "a", "e", "c", "b" ] * a = [ "d", "a", "e", "c", "b" ]
* a.sort! #=> ["a", "b", "c", "d", "e"] * a.sort! #=> ["a", "b", "c", "d", "e"]
* a.sort! { |x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] * a.sort! { |x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
*
* See also Enumerable#sort_by.
*/ */
VALUE VALUE
@ -2526,14 +2526,14 @@ rb_ary_sort_bang(VALUE ary)
* an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ * an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+
* are equivalent, or an integer greater than 0 when +a+ follows +b+. * are equivalent, or an integer greater than 0 when +a+ follows +b+.
* *
* The result is not guaranteed as stable. When comparison of two * The result is not guaranteed to be stable. When the comparison of two
* elements returns +0+, the order of the elements is unpredictable. * elements returns +0+, the order of the elements is unpredictable.
* *
* See also Enumerable#sort_by.
*
* a = [ "d", "a", "e", "c", "b" ] * a = [ "d", "a", "e", "c", "b" ]
* a.sort #=> ["a", "b", "c", "d", "e"] * a.sort #=> ["a", "b", "c", "d", "e"]
* a.sort { |x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] * a.sort { |x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
*
* See also Enumerable#sort_by.
*/ */
VALUE VALUE
@ -2685,11 +2685,12 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, dummy))
* Sorts +self+ in place using a set of keys generated by mapping the * Sorts +self+ in place using a set of keys generated by mapping the
* values in +self+ through the given block. * values in +self+ through the given block.
* *
* The result is not guaranteed as stable. When two keys are equal, * The result is not guaranteed to be stable. When two keys are equal,
* the order of the corresponding elements is unpredictable. * the order of the corresponding elements is unpredictable.
* *
* If no block is given, an Enumerator is returned instead. * If no block is given, an Enumerator is returned instead.
* *
* See also Enumerable#sort_by.
*/ */
static VALUE static VALUE

4
enum.c
View file

@ -935,7 +935,7 @@ enum_first(int argc, VALUE *argv, VALUE obj)
* an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+ * an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+
* are equivalent, or an integer greater than 0 when +a+ follows +b+. * are equivalent, or an integer greater than 0 when +a+ follows +b+.
* *
* The result is not guaranteed as stable. When comparison of two * The result is not guaranteed to be stable. When the comparison of two
* elements returns +0+, the order of the elements is unpredictable. * elements returns +0+, the order of the elements is unpredictable.
* *
* %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"] * %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"]
@ -1011,7 +1011,7 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
* Sorts <i>enum</i> using a set of keys generated by mapping the * Sorts <i>enum</i> using a set of keys generated by mapping the
* values in <i>enum</i> through the given block. * values in <i>enum</i> through the given block.
* *
* The result is not guaranteed as stable. When two keys are equal, * The result is not guaranteed to be stable. When two keys are equal,
* the order of the corresponding elements is unpredictable. * the order of the corresponding elements is unpredictable.
* *
* If no block is given, an enumerator is returned instead. * If no block is given, an enumerator is returned instead.