Reputation: 16842
What is the difference between Ordering.by()
and Ordering.on()
in Scala?
(Well, one is defined in the trait and the other in the companion object, and the implementation code is also different, but there must be a reason why the language needs both.)
Upvotes: 0
Views: 153
Reputation: 15220
From the documentation of Ordering.by
:
This function is an analogue to
Ordering.on
where theOrdering[S]
parameter is passed implicitly.
Basically the two are the same, it's just a matter of convenience depending of what is your context and what you're working with.
Upvotes: 3