k-th largest

Write kth_largest(nums, k) that returns the k-th largest value in the list, counting repeats as separate values (so in [3, 3, 1] the 2nd largest is 3). k is between 1 and len(nums).

kth_largest([3, 2, 1, 5, 6, 4], 2)        ->  5
kth_largest([3, 2, 3, 1, 2, 4, 5, 5, 6], 4)  ->  4

The point is to practise a heap bounded to size k. Sorting also passes; try the heap.

def kth_largest(nums, k):
    ...