challenge ?

alain alainpoint at yahoo.fr
Thu Mar 22 12:41:43 EDT 2007


I have a problem I wonder if it has been solved before.
I have a dictionnary and I want the values in the dictionnary to be
annotated with the rank that would be obtained by sorting the values

def annotate_with_rank(my_dict):
	....
	return my_annotated_dict

In other words, any value a_value would become a 2-tuple
(a_value,rank_of_a_value)

I seek an elegant solution.

Alain




More information about the Python-list mailing list