From: "Hanmac (Hans Mackowiak)" Date: 2013-06-14T03:19:16+09:00 Subject: [ruby-core:55482] [ruby-trunk - Feature #8422] add Enumerable#reverse_sort and Enumerable#reverse_sort_by Issue #8422 has been updated by Hanmac (Hans Mackowiak). my idea would be this, for ruby it may be cood if its converted into C++ code module Enumerable def reverse_sort(&block) block ||= proc {|x,y| x <=> y } sort {|x,y| - block.call(x,y)} end def reverse_sort_by return to_enum(__method__) unless block_given? sort_by{|x| - yield(x)} end end ---------------------------------------- Feature #8422: add Enumerable#reverse_sort and Enumerable#reverse_sort_by https://bugs.ruby-lang.org/issues/8422#change-39915 Author: Hanmac (Hans Mackowiak) Status: Feedback Priority: Normal Assignee: Category: Target version: they are better when you want descending order, enum.sort.reverse does work too, but it is to slow because it needs to build that result array twice they both can be defined just like #sort and #sort_by but negates the result of the compare block -- http://bugs.ruby-lang.org/