Sha256: 8d2c485db09a09b78d9271049a00f6008aef19e6286ccb7f2fe5c4f11a156f02
Contents?: true
Size: 882 Bytes
Versions: 5
Compression:
Stored size: 882 Bytes
Contents
module Alf module Engine # # Implement an in-memory sort, relying on `to_a.sort!` # # Example: # # rel = [ # {:name => "Smith"}, # {:name => "Jones"} # ] # Sort.new(rel, Ordering[[:name, :asc]]).to_a # # => [ # # {:name => "Jones"} # # {:name => "Smith"}, # # ] # class Sort::InMemory < Cog # @return [Enumerable] The operand attr_reader :operand # @return [Ordering] The ordering info attr_reader :ordering # Creates an Autonum instance def initialize(operand, ordering) @operand = operand @ordering = ordering end # (see Cog#each) def each(&block) operand.to_a.sort!(&ordering.sorter).each(&block) end end # class Sort::InMemory end # module Engine end # module Alf
Version data entries
5 entries across 5 versions & 1 rubygems