Method: Array#analyze_and_sort

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

#analyze_and_sortObject



51
52
53
54
55
56
# File 'lib/ptj/ext/datamapper_collection.rb', line 51

def analyze_and_sort
  b = Hash.new(0)
  self.each { | v | b.store(v, b[v]+1) }
  b = b.sort_by { |k,v| -1*v }
  b
end