summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-13 16:30:07 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-13 16:30:07 +0000
commit450307e38315f81c10d959054c49d8baed522027 (patch)
tree55c15b446552b3bfcd27af72a67c236bf0a43cfd /enum.c
parent63fa57e9ba6c25718843c8b223968bea7adc21d4 (diff)
* enum.c (nmin_run): max(n) and max_by(n) returns an array in
descending order. [ruby-core:65452] Suggested by David Grayson. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/enum.c b/enum.c
index 3e25321..633fa54 100644
--- a/enum.c
+++ b/enum.c
@@ -1284,6 +1284,9 @@ nmin_run(VALUE obj, VALUE num, int by, int rev)
ruby_qsort(RARRAY_PTR(result), RARRAY_LEN(result), sizeof(VALUE),
data.cmpfunc, (void *)&data);
}
+ if (rev) {
+ rb_ary_reverse(result);
+ }
*((VALUE *)&RBASIC(result)->klass) = rb_cArray;
return result;