lib/sycsvpro/sorter.rb
def execute
      rows = File.readlines(infile)

      skipped_rows = []

      unless headerless
        skipped_rows[0] = ""
        skipped_rows[0] = rows.shift while skipped_rows[0].chomp.strip.empty?
      end

      if start
        (0...start.to_i).each { |row| skipped_rows << rows.shift }  
      end

      rows.each_with_index do |line, index|
        filtered = col_type_filter.process(row_filter.process(line, row: index))
        next if filtered.nil?
        sorted_rows << (filtered << index)
      end

      File.open(outfile, 'w') do |out|
        skipped_rows.each { |row| out.puts unstring(row) }

        if desc
          sorted_rows.compact.sort.reverse.each do |row|
            out.puts unstring(rows[row.last])
          end
        else
          sorted_rows.compact.sort.each do |row|
            out.puts unstring(rows[row.last])
          end
        end
      end
    end
def execute
      rows = File.readlines(infile)

      skipped_rows = []

      unless headerless
        skipped_rows[0] = ""
        skipped_rows[0] = rows.shift while skipped_rows[0].chomp.strip.empty?
      end

      if start
        (0...start.to_i).each { |row| skipped_rows << rows.shift }  
      end

      rows.each_with_index do |line, index|
        filtered = col_type_filter.process(row_filter.process(line, row: index))
        next if filtered.nil?
        sorted_rows << (filtered << index)
      end

      File.open(outfile, 'w') do |out|
        skipped_rows.each { |row| out.puts unstring(row) }

        if desc
          sorted_rows.compact.sort.reverse.each do |row|
            out.puts unstring(rows[row.last])
          end
        else
          sorted_rows.compact.sort.each do |row|
            out.puts unstring(rows[row.last])
          end
        end
      end
    end
Creates a Sorter and takes as options infile, outfile, rows, cols
 including types and a date format for the date columns to sort (optional).
 :call-seq:
   Sycsvrpo::Sorter.new(infile:     "infile.csv",
                        outfile:    "outfile.csv",
                        rows:       "1,2-5,12-30",
                        cols:       "n:1,s:3",
                        headerless: true,
                        df:         "%d.%m.%Y",
                        start:      "2").execute
 The sorted infile will saved to outfile
 Sorts the data of the infile