summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--array.c5
-rw-r--r--enum.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/array.c b/array.c
index 37a6b2b581..de2f80828a 100644
--- a/array.c
+++ b/array.c
@@ -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.
*/
diff --git a/enum.c b/enum.c
index 56cef1726d..c3a82078a0 100644
--- a/enum.c
+++ b/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