You are viewing a single comment's thread. Return to all comments →
my solution in Go:
type player struct { name string score int } func comparatorSort(players []player) { sort.SliceStable(players, func(i, j int) bool { if players[i].score == players[j].score { return players[i].name < players[j].name } else { return players[i].score > players[j].score } }) for _, v := range players { fmt.Println(v.name, v.score) } }
Seems like cookies are disabled on this browser, please enable them to open this website
Sorting: Comparator
You are viewing a single comment's thread. Return to all comments →
my solution in Go: