โ Back to Polymorphism
Question 571
Implement IComparable
Implement IComparable
MakePersonimplementIComparable<Person>by ordering people byAgeascending. OnceCompareTois defined,List<Person>.Sort()can sort them polymorphically. Do NOT write aMainmethod. After sorting people aged 30, 20, 25 the program prints: B 20 C 25 A 30
Expected Output:
B 20 C 25 A 30
Topics:
Polymorphism
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.