Sha256: d02f77ed02bad8b6395c647d026eac35ca26e3e6378cc6e256d20ea32b55dd00

Contents?: true

Size: 629 Bytes

Versions: 2

Compression:

Stored size: 629 Bytes

Contents

module Quandl
  module Operation
    class Sort
      class << self
        def order?(data)
          return :none if data.blank? || data[0].blank? || data[1].blank?
          data[0][0] > data[1][0] ? :desc : :asc
        end

        def order(data, order = :asc)
          # ascending
          case order
          when :asc   then data = sort_asc(data)
          when :desc  then data = sort_desc(data)
          end
          data
        end

        def asc(data)
          data.sort_by { |r| r[0] }
        end

        def desc(data)
          data.sort_by { |r| r[0] }.reverse
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quandl_operation-0.4.2 lib/quandl/operation/sort.rb
quandl_operation-0.4.2.rc1 lib/quandl/operation/sort.rb