0

I have a tuple that represents a person contains an (ID, overall score, days employed, peer score).

I have decided to put each tuple in a list as follows:

aList = [ aTup, bTup, cTup.....]

I would like to rank people from best to worst based on the rules below. The rules are as follows:

1. People(in this case the tuples) are sorted based on their overall score.
-->If the overall score is the same, sort it by the number of days employed. 
-->If the days employed is the same, sort by peer score.
-->If the peer score is the same, sort by ID(the smaller ID gets preferenced.

Is there a method in python that allows me to achieve this? Something close to the .sort() method?

1 Answer 1

1

The default sort() actually does that for tuples. You only need to make sure that your tuples are of the form (score, days_employed, peer_score, id).

1
  • What if my tuple has other information that I don't need to sort, but need later on? What should I do to handle that case?
    – Shan
    Commented May 29, 2015 at 19:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.