0

I have a list: scores_with_candidates=[score1,score2,candidate] where score1 is the R^2 value and score2 is the MSE and candidate is a string name. Essentially what I want to do is receive a sorted list maybe using scores_with_candidates.sort() in which it sorts the candidates from worst to best based on where both score1 is maximized and score2 is minimized so I would want the candidate with both the highest score1 and lowest score2 at the bottom of the list so that I can retrieve it by using the following command:

best_score1, best_score2, best_candidate = scores_with_candidates.pop()

HM14
  • 689
  • 1
  • 10
  • 30
  • Maybe `sorted` with a key could be of some help? http://stackoverflow.com/questions/72899/how-do-i-sort-a-list-of-dictionaries-by-values-of-the-dictionary-in-python?rq=1 – zezollo Mar 08 '17 at 16:55
  • What would you expect if the candidate with the highest score1 is not the same candidate as the one with the lowest score2? They can't both be at the bottom of the list... Also, it might be that one candidate has the highest of both scores, implying it should both be at the top and the bottom of the list at the same time... – twalberg Mar 08 '17 at 18:32

0 Answers0