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).

Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.