Sha256: 64e8a8ce04f38909a77c7f3a6feba32e9ad7c12a525e40a0026bafb88c617927

Contents?: true

Size: 365 Bytes

Versions: 1

Compression:

Stored size: 365 Bytes

Contents

require "sortplus/version"

module SortPlus

  def self.array_sort(arry,ind,asc)
  	my_h = arry.each_with_object({}) { |a,h| h.has_key?(a[ind]) ? h[a[ind]] << a : h[a[ind]] = [a] }
  	keys = asc ? my_h.keys.sort : my_h.keys.sort.reverse
  	keys.each_with_object([]) do |a,l|
  	  mat = asc ? my_h[a] : my_h[a].reverse
  	  mat.each { |m| l << m }
  	end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sortplus-0.2.4 lib/sortplus.rb