Method: DataMapper::Collection#analyze_and_sort

Defined in:
lib/ptj/ext/datamapper_collection.rb

#analyze_and_sortObject



16
17
18
19
20
21
22
23
24
# File 'lib/ptj/ext/datamapper_collection.rb', line 16

def analyze_and_sort
  b = Hash.new(0)
  self.each do |item|
    meth = item.method(entry)
    b[meth.call()] += 1
  end
  b = b.sort_by { |k,v| -1*v }
  b
end