どういう並べ替えをする方法なの?
value を昇順に並べ替えた上で、 同じ value を持つ key についても昇順にする方法です。
具体的には、
# これを
{3: 10, 2: 20, 1: 10}
# こうする
{1: 10, 3: 10, 2: 20}
方法です。
方法
追記
コメントでこちらの方が簡単だと教えていただきました。
hash.sort_by{ |k, v| [v, k] }.to_h
仕組みはよく分かりませんが、いろいろ試した所出来たので投稿します。
# いったん Array に変換
array = hash.to_a
# key value を同時に昇順に変換
array.sort_by! {|x| [x[1], x[0]]}
# Hash に戻す
hash = array.to_h