Module: CoreExtensions::Array::DuplicatesCounter
- Defined in:
- lib/extensions/class-extensions.rb
Instance Method Summary collapse
Instance Method Details
#count_duplicates ⇒ Object
4 5 6 |
# File 'lib/extensions/class-extensions.rb', line 4 def count_duplicates self.each_with_object(Hash.new(0)) { |element, counter| counter[element] += 1 }.sort_by{|k,v| -v}.to_h end |