Sha256: 937386d9a3501f55ee8ee0b56effc55694c1c3a383f1571023f26050b69e761e

Contents?: true

Size: 214 Bytes

Versions: 6

Compression:

Stored size: 214 Bytes

Contents

class Array
  def histogram
    histogram = each_with_object(Hash.new(0)) {|n, memo| memo[n] += 1}.sort_by{|k, v| -v}

    return Hash[histogram]
  end

  def by_popularity    
    return histogram.keys
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
creative_rails_utilities-0.4.8 lib/creative_rails_utilities/array.rb
creative_rails_utilities-0.4.7 lib/creative_rails_utilities/array.rb
creative_rails_utilities-0.4.6 lib/creative_rails_utilities/array.rb
creative_rails_utilities-0.4.5 lib/creative_rails_utilities/array.rb
creative_rails_utilities-0.4.4 lib/creative_rails_utilities/array.rb
creative_rails_utilities-0.4.3 lib/creative_rails_utilities/array.rb