Adding a ranking based on two fields

noydb jenn.duerr at
Thu Aug 25 22:38:28 CEST 2011

Hello All,

Looking for some advice/ideas on how to implement a ranking to a
'scores' field I have.  So this scores field has values ranging from
1.00-4.  There is also a count field.  I want to add a rank field such
that all the records have a unique ranking, 1 through the number of
records (thousands).  The rank is based on the score first, the count
second.  So, a record with a score of 4 and a count of 385 is ranked
higher than a record with a score of 4 and a count of 213 AND higher
than record with a score of 3.25 with a count of 4640.

My thought was to add the unique score values to a list and loop thru
the list... sort records with score=listItem, add ranking... not quite
sure how to do this!

Any help would be much appreciated!

More information about the Python-list mailing list