How to sort this type of nested list without splitting the list into separate?
class Car:
    def __init__(self, carid, carname):
        self.carid = id
        self.carname = name
    def __str__(self):
        return str(self.__dict__)
def cars():
    car_car = [ Car(3, "toyota"),
                Car(4, "BMW"),
                Car(2, "Chevloret"),
                Car(1,"Ford")]
    cars.sort(key=lambda v: (v[0], v[1])) ### here
    return car_car
I want to sort the data alphabetically using the .sort option without splitting that list
I got
TypeError: 'Car' object is not subscriptable error
with sorted() and .sort()
 
     
    