-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdunder_method_lt_github.py
More file actions
42 lines (32 loc) · 999 Bytes
/
dunder_method_lt_github.py
File metadata and controls
42 lines (32 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Resume:
def __init__(self, candidate: str, score: int):
self.candidate = candidate
self.score = score
def __lt__(self, other):
"""
Custom sorting rule:
Higher score → higher priority
(reverse comparison to get descending order)
"""
return self.score > other.score
def __repr__(self):
return f"{self.candidate} (Score: {self.score})"
class ResumeSorter:
def __init__(self, resumes: list):
self.resumes = resumes
def sort_resumes(self):
print("\nSorting resumes by candidate score...")
sorted_list = sorted(self.resumes)
for r in sorted_list:
print(" -", r)
def main():
resumes = [
Resume("Betül", 92),
Resume("Alex", 80),
Resume("John", 75),
Resume("Emily", 88)
]
sorter = ResumeSorter(resumes)
sorter.sort_resumes()
if __name__ == "__main__":
main()