1

The code below is two list that have been sorted from highest to lowest, with numerical values being read from a text file. I am trying to use these variables to write a league table, with the points (premier_league) being the primary variable, and the goal difference (goal_difference) being the secondary variable. If two of the variables in the premier_league list are equal, then the goal difference should be taken into account as to where they should be in the table.

premier_league = sorted([ARS_P,BOU_P,BRI_P,BUR_P,CAR_P,CHE_P,CRY_P,EVE_P,FUL_P,HUD_P,LEI_P,LIV_P,MANC_P,MANU_P,NEW_P,SOU_P,TOT_P,WAT_P,WHU_P,WOL_P,], reverse=True)
goal_difference = sorted([ARS_D,BOU_D,BRI_D,BUR_D,CAR_D,CHE_D,CRY_D,EVE_D,FUL_D,HUD_D,LEI_D,LIV_D,MANC_D,MANU_D,NEW_D,SOU_D,TOT_D,WAT_D,WHU_D,WOL_D,], reverse=True)

This isn't necessary but if there was a way to make is so that when the order of the table has been determined, the corresponding team to each variable is written into the text file in that order as well. Thanks.

BTemple28
  • 11
  • 2
  • 4
    I don't see any data to sort in your question. Can you provide a **[mcve]**? – jpp Sep 24 '18 at 15:33
  • @Jean-FrançoisFabre yes this is a duplicate – vash_the_stampede Sep 24 '18 at 15:41
  • answer from the duplicate answers, even if question is slightly different. Here the question isn't complete missing actual data as jpp noted. So ... let's move on. – Jean-François Fabre Sep 24 '18 at 15:43
  • I don't think that it's a duplicate. @BTemple28 wants to sort a custom object using two variables. If the first is equal, then sort using the other. Something like a comparator based sort in Java. Or, maybe I am wrong, since OP hasn't explained his question properly – MaJoR Sep 24 '18 at 15:53
  • @MaJoR the way the duplicate link answers works 100% for this case. I had answered but deleted the answer – Jean-François Fabre Sep 24 '18 at 15:54

0 Answers0