Peter Otten wrote, on January 09, 2017 3:27 PM > > While stable sort is nice in this case you can just say > > key=operator.attrgetter("Description", "Date") > > Personally I'd only use sorted() once and then switch to the > sort() method.
This works perfectly, thank you. As I read the docs, the main (only?) difference between sorted() and .sort() is that .sort() sorts the list in place. Since I won't change the order of the records again after the sort, I'm using records.sort(key=operator.attrgetter("Description", "Date")) once, which also works perfectly. So both sorted() and sort() can be used to sort namedtuples. Good to know! -- https://mail.python.org/mailman/listinfo/python-list