How do I sort a list of datetime or date objects?

You’re getting None because list.sort() it operates in-place, meaning that it doesn’t return anything, but modifies the list itself. You only need to call a.sort() without assigning it to a again.

There is a built in function sorted(), which returns a sorted version of the list – a = sorted(a) will do what you want as well.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)