Sorting
Algorithms ⟩ Sorting ⟩
seq.sorted(_:) - sort by keypaths with ascending/descending orders
the sorted(by:) function is actually 2 different functions.
one requires
Comparableand uses<internally.the other lets you specify the sorting logic directly (
Comparableconformance not required).
... this convenience sorting by keyPath would still require 2 functions.
👉 Reference default comparison function as a function parameter
Last updated