summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-07 13:02:35 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-07 13:02:35 +0000
commitf2fc478054edd33a8b574475d4f6704e4a6db747 (patch)
treec26b0a374f973c36598d6d8725b8ceed0ed01930 /lib
parent5c6028ecb373d3ebd6dc94d51763b0113be288ba (diff)
downloadruby-f2fc478054edd33a8b574475d4f6704e4a6db747.tar.gz
ruby-f2fc478054edd33a8b574475d4f6704e4a6db747.tar.xz
ruby-f2fc478054edd33a8b574475d4f6704e4a6db747.zip
* lib/pp.rb (PP::PPMethods#pp_hash): sort condition changed:
all keys have a same class which is kind of Comparable. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/pp.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index e92ab014a..53ecaedd5 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -248,10 +248,11 @@ class PP < PrettyPrint
def pp_hash(obj)
group(1, '{', '}') {
keys = obj.keys
- if keys.all? {|k| k.respond_to? :to_str } ||
- keys.all? {|k| k.is_a? Symbol } ||
- keys.all? {|k| k.is_a? Integer }
- keys.sort!
+ 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]