How to compare two classes datas?
CodePudding user response:
What you are looking for is called KeyPathComparator
. You can pass as many properties as needed when sorting your collection:
let sorted = userItems.sorted(using: [.init(\.savedOn, order: .reverse), .init(\.title, order: .reverse))