Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
array = %w[a b a b c d e g j a e c d k o k i l p a e c f d e a d e f s d v c ]
result = Hash[array.each_with_object(Hash.new(0)) {|e, h| h[e] += 1 }.sort_by {|k,v| -v}].keys
array = %w[a b a b c d e g j a e c d k o k i l p a e c f d e a d e f s d v c ]
array.sort_by {|v| -array.count(v)}.uniq
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question