def solution(n, stages):
answer = []
percent_fail = {}
stage_of_people = len(stages)
for i in range(1, n+1) #1부터 n+1까지 순서대로 count(i) 출력
counter = stages.count(i)
if stage_of_people == 0: # 스테이지에 도전한 사람이 0이면 실패율 0
percent_fail[i] = 0
else: #실패율 : 스테이지에 도전중인 사람 / 스테이지에 도달한 사람 수
percent_fail[i] = counter / stage_of_people
stage_of_people = stage_of_people - counter # 스테이지에 도달한 사람 수 - i의 개수
answer = [i[0] for i in sorted(percent_fail.items(), key = lambda x: (-x[1],x[0]))]
return answer
(percent_fail.items(), key = lambda x: (-x[1],x[0]))
[i[0] for i in sorted(리스트)]