Find the kth largest integer

How would we pick the kth largest integer in an array?

arr = [1, 0, -34, 53, 654, 24.23, 5323, 80, 80, -11, 0, 100000]
desc = sorted(arr, reverse=True)

def kth_largest(k, arr):
    if k == 1:
        return max(arr)
    list(filter(lambda x: x != max(arr), desc)
    return desc[k]

print(kth_largest(2, arr))

I came across a solution on the platform but I don’t think that really worked. I have tried to implement the logic I understood but I get an error running the syntax above, ”’SyntaxError: invalid syntax”’ on the return desc[k].

A brief explanation for the logic behind the code/explanation suggested would be much appreciated as well if possible.

Answer

k-th largest integer, ommiting the duplicates:

import math

arr = [1, 0, -34, 53, 654, 24.23, 5323, 80, 80, -11, 0, 100000, 2.0, 2.0]
k_index = 4

sorted(set(x for x in arr if x-math.floor(x)==0), reverse=True)[k_index]

>> 53