# File lib/mongoid/criterion/optional.rb, line 135 def order_by(*args) clone.tap do |crit| arguments = args.size == 1 ? args.first : args crit.options[:sort] = [] unless options[:sort] || args.first.nil? if arguments.is_a?(Array) #[:name, :asc] if arguments.size == 2 && (arguments.first.is_a?(Symbol) || arguments.first.is_a?(String)) build_order_options(arguments, crit) else arguments.each { |argument| build_order_options(argument, crit) } end else build_order_options(arguments, crit) end end end