Regarding sorted

Can you tell me how to do this.
I have been using this

class Obj:

def __init__(self, a=0, b=1):
    self.a = a
    self.b = b

if name == “main”:

def getmykey(obj):
    key = obj.b

return key

    objects = [Obj(1, 2), Obj(5, 4), Obj(7, 3),Obj(11, 42), Obj(8, 0), Obj(5, 9)]
    print(sorted( objects ,key=getmykey))

Hey @shubham_sinha, yes you are doing it completely right, just change last 2 lines to

 objects = sorted(objects, key = getmykey)
 for ix in objects:
     print(ix.a, ix.b) 

Hope this resolved your doubt.
Plz mark it as resolved in my doubts section. :blush: