def print_array_of_arrays(nested_array)
      nested_sizes = nested_array.map do |row|
        row.map { |element| element.to_s.size }
      end

      sizes = nested_sizes.transpose.map { |row| row.max }

      nested_array.each do |row|
        line_elements = row.each_with_index.map do |element, index|
          element_string = element.kind_of?(Array) ? element.join(', ') : element.to_s
          element_string.ljust(sizes[index] + 1, ' ')
        end

        puts line_elements.join(' | ').prepend("  ")
      end
    end
def print_array_of_arrays(nested_array)
      nested_sizes = nested_array.map do |row|
        row.map { |element| element.to_s.size }
      end

      sizes = nested_sizes.transpose.map { |row| row.max }

      nested_array.each do |row|
        line_elements = row.each_with_index.map do |element, index|
          element_string = element.kind_of?(Array) ? element.join(', ') : element.to_s
          element_string.ljust(sizes[index] + 1, ' ')
        end

        puts line_elements.join(' | ').prepend("  ")
      end
    end
TODO
 sort output by number of lines or any param