Python Forum
Use ranking function for different lists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use ranking function for different lists
#1
Hi.

I have a function that i use to rank a list from highest to lowest, right now it is hard coded to one list, what i would like to be able to do is pass lists to it.


def rank():
    global mons
    dict = {}
    for i, e in enumerate(mons):                   
        dict[e] = i                                
    rank = 1                                      
    for key in sorted(dict.keys(), reverse=TRUE):
        mons[dict.get(key)] = rank                 
        rank = rank + 1       
Reply


Messages In This Thread
Use ranking function for different lists - by klatlap - Feb-12-2022, 09:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pop function for lists jamesaarr 8 2,715 Aug-26-2021, 06:40 PM
Last Post: ndc85430
  drf ordering by custom field and add ranking in to_representation tomfong521 0 1,888 Mar-24-2021, 09:56 AM
Last Post: tomfong521
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,455 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Reading Multiple Lists Using SUM function dgrunwal 6 3,417 Jun-03-2020, 08:23 PM
Last Post: dgrunwal
  Money conversion - problems with lists and .format function fatherted99 1 1,849 Mar-12-2020, 06:29 PM
Last Post: ndc85430
  Using function argument in lists comprehension. blackknite 5 3,106 Apr-23-2019, 09:59 PM
Last Post: snippsat
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,327 Mar-20-2019, 08:01 PM
Last Post: stillsen
  Help with plot, how to show ranking with boxes icebelt 1 2,482 Jan-25-2019, 10:00 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020