From: Thomas Sawyer Date: 2012-02-28T08:11:08+09:00 Subject: [ruby-core:42984] [ruby-trunk - Feature #6079] Hash#each_sorted Issue #6079 has been updated by Thomas Sawyer. =begin {1 => 2, 0 => 4}.lazy.sort.each{|k, v| p "#{k} => #{v}"} =end ? ---------------------------------------- Feature #6079: Hash#each_sorted https://bugs.ruby-lang.org/issues/6079 Author: Walter Urbaniak Status: Open 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/