Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/tanakai/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#in_sorted_groups(number, fill_width = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/tanakai/core_ext/array.rb', line 2

def in_sorted_groups(number, fill_width = nil)
  sorted_groups = Array.new(number) { |a| a = [] }

  self.in_groups_of(number, fill_width).each do |group|
    number.times do |i|
      group.fetch(i) rescue next
      sorted_groups[i] << group[i]
    end
  end

  sorted_groups
end