I have this struct of locations:
struct Location: Identifiable, Codable {
var id: String
var name: String
var country: String
}
I can easily sort this by name:
self.userData = self.userData.sorted(by: {$0.name < $1.name })
But I also want the ability to put locations with a particular country first in the list.
I tried this:
self.userData.sorted(by: { ($0.country == "United States"), ($0.name < $1.name) })
but I get an error "Consecutive statements on a line must be separated by ;".
How can I sort alphabetically by a particular country first? Then sort the remaining locations alphabetically by the name property.