add comments to mention sort.reverse!

For array.c (Array#sort) and enum.c (Enumerable#sort_by),
add comments mentioning that sort.reverse! / sort_by { ... }.reverse!
can/should be used to reverse the result. [ci skip]
This commit is contained in:
Martin Dürst 2019-06-13 15:30:03 +09:00
Родитель 2a26c1ea24
Коммит 7f79a86d8b
2 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -2819,6 +2819,11 @@ rb_ary_sort_bang(VALUE ary)
* ary.sort #=> ["a", "b", "c", "d", "e"]
* ary.sort {|a, b| b <=> a} #=> ["e", "d", "c", "b", "a"]
*
* To produce the reverse order, the following can also be used
* (and may be faster):
*
* ary.sort.reverse! #=> ["e", "d", "c", "b", "a"]
*
* See also Enumerable#sort_by.
*/

4
enum.c
Просмотреть файл

@ -1220,6 +1220,10 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
*
* sorted = Dir["*"].sort_by { |f| test(?M, f) }
* sorted #=> ["mon", "tues", "wed", "thurs"]
*
* To produce the reverse of a specific order, the following can be used:
*
* ary.sort_by { ... }.reverse!
*/
static VALUE