lib/tablesmith/hash_rows_base.rb in tablesmith-0.2.1 vs lib/tablesmith/hash_rows_base.rb in tablesmith-0.2.2
- old
+ new
@@ -5,9 +5,10 @@
all_keys = rows.map(&:keys).flatten.uniq
rows.map { |hash_row| all_keys.each { |key| hash_row[key] ||= '' } }
end
def sort_columns(rows)
+ return if column_order.empty?
rows.map! do |row|
# this sort gives preference to column_order then falls back to alphabetic for leftovers.
# this is handy when columns auto-generate based on hash data.
row.sort do |a, b|
a_col_name, b_col_name = [a.first, b.first]
\ No newline at end of file