Top k items by score
Your task
Given items, a list of [id, score] pairs (id is a string, score is a number), return the ids of the top k items by score, highest first. Break ties between equal scores by the id in ascending lexicographic order. If k exceeds the number of items, return all of them in ranked order. k >= 0. Return the list of ids.
Examples
top_k(items: list[list], k: int) -> list[str]Example 1
Input
top_k([["a", 3], ["b", 5], ["c", 1]], 2)Output
["b", "a"]