books = [[2001, 50, 5], [2002, 50, 3], [2003, 40, 2]]

books.sort(key=lambda x: (-x[1], x[2], x[0]))

answer = []

for i in range(len(books)):
    answer.append(books[i][0])

print(answer)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: