From 90bd103b8b91effe85402ae6936e5711c659c3cb Mon Sep 17 00:00:00 2001 From: Jeff Ward Date: Thu, 12 Oct 2017 14:49:40 -0600 Subject: [PATCH] Possible fix for issue #5 Sort the hashes, not every array. Maybe not the prettiest fix, but it works. --- lib/crimp.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/crimp.rb b/lib/crimp.rb index ad75a86..c6067a8 100644 --- a/lib/crimp.rb +++ b/lib/crimp.rb @@ -27,7 +27,7 @@ def self.convert(obj) def self.hash_to_array(hash) [].tap do |a| - hash.each { |k, v| a << pair_to_string(k, v) } + hash.map { |k,v| [stringify(k),v] }.sort { |a,b| a[0].to_s <=> b[0].to_s }.each { |val| a << pair_to_string(val[0],val[1]) } end end @@ -36,7 +36,7 @@ def self.pair_to_string(k, v) end def self.parse_array(array) - array.map { |e| stringify(e) }.sort + array.map { |e| stringify(e) } end def self.parse_hash(hash)