Permalink
Browse files

hash.rb: each_pair_sort_keys, each_pair_sort_values

  • Loading branch information...
quix committed Aug 9, 2009
1 parent 40c091e commit e736d405a9287af9261a54d5946e019fc8d4fd40
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/quix/ext/hash.rb
  2. +2 −2 test/hash_test.rb
View
@@ -6,14 +6,14 @@ def of(klass, *args)
end
end
- def key_sorted_each_pair
+ def each_pair_sort_keys
keys.sort.each { |key|
yield key, self[key]
}
self
end
- def value_sorted_each_pair
+ def each_pair_sort_values
inverted = invert
values.sort.each { |value|
yield inverted[value], value
View
@@ -11,13 +11,13 @@ def test_hash
}
memo = Array.new
- s.key_sorted_each_pair { |key, value|
+ s.each_pair_sort_keys { |key, value|
memo << key
}
assert_equal %w[x y z], memo
memo = Array.new
- s.value_sorted_each_pair { |key, value|
+ s.each_pair_sort_values { |key, value|
memo << key
}
assert_equal %w[y x z], memo

0 comments on commit e736d40

Please sign in to comment.