From 9d326d261ef24dc4ba0b66be29f12fcacb9be52d Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 14 Oct 2007 02:14:16 +0000 Subject: * 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 --- lib/pp.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'lib/pp.rb') diff --git a/lib/pp.rb b/lib/pp.rb index 53ecaedd59..b815a0d499 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -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 -- cgit v1.2.1