Ranking by likes

Write code · Medium · §6.1 Putting things in order

likes holds the number of likes each post received. likes[i] is the number of likes for post i.

Complete the function solution, which returns a list of the post numbers in order from the most likes to the fewest. If two posts have the same number of likes, the smaller post number comes first.

Function

solution(likes)

Constraints

Examples

likesresult
[5, 9, 5, 1][1, 0, 2, 3]
[0][0]

Starter code

def solution(likes):
    answer = []
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.