method
List.sort_desc_by
List.sort_desc_by(s, key) -> void
Like List.sort_by, but descending — highest key first. The everyday case is a leaderboard: sort players by score so the top scorer lands at index 0. key is a function taking one element and returning a number (int, fixed, or long). The sort is stable (O(n log n) merge sort): players tied on score keep their prior order, so a stable tie-break (say, who reached the score first) survives the sort.
Example
# doc-check: skip — illustrative; `key` is any fn(element) -> number in scope
function score_of(p: Player) -> int { return p.score }
program Demo {
handler Step phase Update {
List.sort_desc_by(players, score_of) # players[0] is the leader
}
}