From acbffce267b63bb06281f3ebe6a8bb0d897d4566 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 7 Jul 2007 13:02:35 +0000 Subject: [PATCH] * lib/pp.rb (PP::PPMethods#pp_hash): sort condition changed: all keys have a same class which is kind of Comparable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/pp.rb | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94769a1306..f6ef4af7e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jul 7 21:59:29 2007 Tanaka Akira + + * lib/pp.rb (PP::PPMethods#pp_hash): sort condition changed: + all keys have a same class which is kind of Comparable. + Sat Jul 7 17:12:37 2007 Koichi Sasada * compile.c: use rb_bug() instead of rb_compile_error(). diff --git a/lib/pp.rb b/lib/pp.rb index e92ab014a7..53ecaedd59 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]