I have an array of a custom class
class GameInfo {
var gameStatus :String
var country : String
var isSelected : Bool
}
Here, gameStatus may be "*"/"1-0"/"1/2-1/2"
I want to sort the array first by isSelected, then gameStatus, then country.
I tried sortInPlace but didn't work for me.
suppose this is my array
let list = [
GameInfo(gameStatus: "*", country: "Italy", isSelected: true),
GameInfo(gameStatus: "1/2-1/2", country: "France", isSelected: true),
GameInfo(gameStatus: "1-0", country: "Italy", isSelected: false),
GameInfo(gameStatus: "*", country: "Germany", isSelected: false),
GameInfo(gameStatus: "0-1", country: "Italy", isSelected: true),
GameInfo(gameStatus: "1/2-1/2", country: "France", isSelected: false),
GameInfo(gameStatus: "*", country: "UK", isSelected: false)
]
Selected games should be on top if with in selected game there is any live game that game should be on top even with in any game related to my country that game on top
suppose my country is Italy then sorted order of array is
GameInfo(gameStatus: "*", country: "Italy", isSelected: true),
GameInfo(gameStatus: "0-1", country: "Italy", isSelected: true),
GameInfo(gameStatus: "1/2-1/2", country: "France", isSelected: true),
GameInfo(gameStatus: "*", country: "Germany", isSelected: false),
GameInfo(gameStatus: "*", country: "UK", isSelected: false)
GameInfo(gameStatus: "1-0", country: "Italy", isSelected: false),
GameInfo(gameStatus: "1/2-1/2", country: "France", isSelected: false),