[Solved] list populate by append function can’t be sorted by sort function


I think you may have to be more specific and provide a comparison function so that your list can be sorted. Took the code below from the following site. Hope it helps:

https://wiki.python.org/moin/HowTo/Sorting

    >>> student_tuples = [
            ('john', 'A', 15),
            ('jane', 'B', 12),
            ('dave', 'B', 10),
    ]
    >>> sorted(student_tuples, key=lambda student: student[2])   # sort by age
    [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

solved list populate by append function can’t be sorted by sort function