From: Marc-Andre Lafortune Date: 2012-03-06T13:21:00+09:00 Subject: [ruby-core:43083] [ruby-trunk - Feature #6079][Rejected] Hash#each_sorted Issue #6079 has been updated by Marc-Andre Lafortune. Status changed from Open to Rejected Closing as no implementation can improve on simple `sort.each`. ---------------------------------------- Feature #6079: Hash#each_sorted https://bugs.ruby-lang.org/issues/6079 Author: Walter Urbaniak Status: Rejected Priority: Normal Assignee: Category: Target version: I often use my own mixin'd Hash#each_sorted that sorts the hash keys and then calls the block with the key and value. It would be useful to be added to Hash. (If this is already in Hash or Enumerable, I didn't see it.) class Hash def each_sorted(&block) # sort by key self.keys.sort.each {|key| block.call(key, self[key])} end end -- http://bugs.ruby-lang.org/