instance method
compare_values_for_order
Ruby on Rails 8.1.2
Since v8.0.4 PrivateAvailable in: v8.0.4 v8.1.2
Signature
compare_values_for_order(values1, values2, order)
This is a custom implementation of ‘<=>` operator, which also takes into account how the collection will be ordered.
Parameters
-
values1req -
values2req -
orderreq
Source
# File activerecord/lib/active_record/relation/batches.rb, line 414
def compare_values_for_order(values1, values2, order)
values1.each_with_index do |element1, index|
element2 = values2[index]
direction = order[index]
comparison = element1 <=> element2
comparison = -comparison if direction == :desc
return comparison if comparison != 0
end
0
end
Defined in activerecord/lib/active_record/relation/batches.rb line 414
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Batches