title: sorting by frequency of occurrence in an array
body: <p>Is there an efficient way of doing this. I have an array </p>
  
  <pre><code>a=[1,2,2,3,1,2]
  </code></pre>
  
  <p>I want to output the frequency of occurrence in an ascending order. Example</p>
  
  <pre><code>[[3,1],[1,2],[2,3]]
  </code></pre>
  
  <p>Here is my code in ruby.</p>
  
  <pre><code>b=a.group_by{|x| x}
  out={}
  
  b.each do |k,v|
      out[k]=v.size
  end
  
  out.sort_by{|k,v| v}
  </code></pre>