how can i delete duplicate values from a hash of hash

I need a unique hash , where the value of “one” should never repeat.

for example,

hash= {"1"=>{"one"=>1,"two"=>2},
   "2"=>{"one"=>1,"two"=>3},
   "3"=>{"one"=>2,"two"=>3},
   "4"=>{"one"=>1,"two"=>2}}

then the result should be,

hash= {"1"=>{"one"=>1,"two"=>2},
    "3"=>{"one"=>2,"two"=>3}}


Source: ruby

Leave a Reply