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