Added #each_sorted method to Hash. Allows sorted iteration
identical to #each (except the keys are sorted).
e.g.
original = {'c' => 3, 'a' => 1, 'b' => 2, 'd' => 4}
expected = [['a',1],['b',2],['c',3],['d',4]]
original.each_sorted do |key, value|
# key will be a,b,c,d etc on each iteration in order
assert_equal expected.shift, [key, value]
end
Made change after watching http://railscasts.com/episodes/2...
and realizing I'd had the same problem myself a few times.