Help ranking values

I noticed the Excel equivalent RANK() functions in Grist are not yet implemented. Is there a Python equivalent or some other way that I can easily come up with a value’s rank within a subset of values in a table?

I am new to Python, so I searched for something like that but wasn’t able to find an easy way to achieve that.


A rough translation to python, ignoring issues about duplicates, could maybe be to sort the list and then use index:

>>> sorted([10, 50, 1, 7, 42]).index(7)
>>> sorted([10, 50, 1, 7, 42]).index(50)
>>> sorted([10, 50, 1, 7, 42]).index(1)

(first-ranked item will have rank 0 with this method). Sorting is a bit inefficient when just looking for rank of a single element, but it might be fine depending on what you’re trying to do.

Thanks Paul, I’ll give that a try!