"Rank" a list of nodes based on a shared property

Hello, I'm trying to assign a "rank" to nodes based on a property. In this case, I have Persons, and they have Calls.
The higher the call amount, the "better" the rank. People who are tied for Calls should have the same rank (as seen in the image below):
image

My current code:

match(p:Person)-[:HAD_CALL]->(e:Call)
with p, count(e) as test
with collect([p, test]) as nodes
unwind range(0, size(nodes)-1) as rank
return nodes[rank][0].name as PersonName, nodes[rank][1] as Count, rank order by Count desc

My code gives results like this (I have nearly ~100,000 nodes):
image

Is there any way for me to rank nodes based on a property value, while cleaning handling ties?

Thank you!

you could collect them by count before you determine the rank

match(p:Person)
with p, count { (p)-[:HAD_CALL]->() } as calls
with calls, collect(p) as people order by calls desc
with collect([calls, people]) as all
unwind range(0, size(all)-1) as rank
unwind all[rank][1] as p
return rank, all[rank][0] as calls, p
2 Likes