Module: CoreExtensions::Array::DuplicatesCounter

Included in:
Array
Defined in:
lib/ib/market-price.rb

Instance Method Summary collapse

Instance Method Details

#count_duplicatesObject



5
6
7
# File 'lib/ib/market-price.rb', line 5

def count_duplicates
  self.each_with_object(Hash.new(0)) { |element, counter| counter[element] += 1 }.sort_by{|k,v| -v}.to_h
end