Sort method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
13th Feb 2019, 6:24 AM
Susanta Paul
Susanta Paul - avatar
3 Answers
+ 4
employee is a class. employee.name refers to a class variable "name" that doesn't exist. With self.name within __init__, you define instance variables. They can be used for sorting just as your code does (lambda x: x.name)
13th Feb 2019, 6:41 AM
Anna
Anna - avatar
0
Please help me to fix above code
13th Feb 2019, 6:25 AM
Susanta Paul
Susanta Paul - avatar
0
Anna thanks a lot confusion cleared
13th Feb 2019, 7:27 AM
Susanta Paul
Susanta Paul - avatar