diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-14 02:14:16 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-14 02:14:16 +0000 |
commit | 9d326d261ef24dc4ba0b66be29f12fcacb9be52d (patch) | |
tree | 75e5837cec7315e422b42106a9d3b95b3dae3820 /lib/pp.rb | |
parent | b933a5348bcbbaebae8710286ae4727612a58e4e (diff) |
* lib/pp.rb (PP::PPMethods#pp_hash): don't sort keys because hash is
ordered.
(ENV.pretty_print): call pp_hash with sorted hash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pp.rb')
-rw-r--r-- | lib/pp.rb | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -247,15 +247,7 @@ class PP < PrettyPrint def pp_hash(obj) group(1, '{', '}') { - keys = obj.keys - if 0 < keys.length - key_class = keys[0].class - if key_class < Comparable && keys.all? {|k| k.class == key_class } - keys.sort! - end - end - seplist(keys, nil, :each) {|k| - v = obj[k] + seplist(obj, nil, :each_pair) {|k, v| group { pp k text '=>' @@ -359,7 +351,11 @@ end class << ENV def pretty_print(q) - q.pp_hash self + h = {} + ENV.keys.sort.each {|k| + h[k] = ENV[k] + } + q.pp_hash h end end |