title: Sorting Hash by value
body: <p>I want to sort my has by value.I am tried to sort my hash this <a href="https://stackoverflow.com/questions/4264133/descending-sort-by-value-of-a-hash-in-ruby">way</a> and it does not work, I don't know why.
  This is my code:</p>
  
  <pre><code>test="neki text sa recima neki sa i jos neki aa"
  mapa=Hash.new(0)
  test.split(" ").each do |rec|
      mapa[rec]+=1
  end
  
  mapa.sort_by {|a,b| b}.reverse
  
  mapa.each do |key, value|
      puts "#{key} #{value}" 
  end
  </code></pre>
  
  <p>the output is :</p>
  
  <pre><code>neki 3
  text 1
  sa 2
  recima 1
  i 1
  jos 1
  aa 1
  </code></pre>
  
  <p>It doesn't do anything to the HASH :/
  Can someone explain to me why it does not work? </p>
  
  <p>if you give me a MINUS please explain in the comment what I did to deserve it so I know where to improve. :)</p>