Rating of list items

PHOTO EMBED

Thu Nov 03 2022 05:16:05 GMT+0000 (Coordinated Universal Time)

Saved by @pika8oo #python #list

>>> l = [-1, 3, 2, 0,0]
>>> [sorted(l).index(x) for x in l]
[0, 4, 3, 1, 1]
content_copyCOPY

https://stackoverflow.com/questions/3071415/efficient-method-to-calculate-the-rank-vector-of-a-list-in-python