Home

> ....
> "beginner"'s advice to use a dictionary is also good
> and may turn out to be faster, just because dicts are
> SO fast in Python -- but you need to try and measure
> both alternatives.
>
> One way to use a dict ( warning, untested code ) :

def rank_list( single_list ) :

d = { }

for i , item in reversed( enumerate( sorted( single_list ) ) ) :

d[ item ] = i

return [ d[ item ] for item in single_list ]


Alex ....

I tested it but I don't know how to fix it .... :-)

Both Pablo's original version and Neil's version work
but I get the following traceback from your version ....

Traceback (most recent call last):
File "list_nested_rank.py", line 100, in <module>
test_01( list_source )
File "list_nested_rank.py", line 87, in test_01
list_print( this_func( list_source ) )
File "list_nested_rank.py", line 62, in rank_lists_02
return map( rank_list , nested_list )
File "list_nested_rank.py", line 56, in rank_list
for i , item in reversed( enumerate( sorted( single_list ) ) ) :
TypeError: argument to reversed() must be a sequence



--
Stanley C. Kitching
Human Being
Phoenix, Arizona


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

previous
next

Game of craps giving class error
assignment operator
Re: platform system may be Windows or Microsoft since Vista
Re: Select as dictionary...
Re: distinguishing wheter void* ptr points to class A or class B?
Zaproszenia ślubne zasłony nowe mieszk
midface lift
regały sklepowe
buty do tańca
ubranka dla niemowląt