J
Jason
Hi folks--
Basically, I have a pressing need for a combination of 5.2 "Sorting a
List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects
by an Attribute of the Objects" from the Python Cookbook.
My first guess isn't working:
import operator
def sort_by_attr(seq, attr):
key=operator.attrgetter(attr)
key=str.lower
return sorted(seq, key)
....would much appreciate any guidance!
Basically, I have a pressing need for a combination of 5.2 "Sorting a
List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects
by an Attribute of the Objects" from the Python Cookbook.
My first guess isn't working:
import operator
def sort_by_attr(seq, attr):
key=operator.attrgetter(attr)
key=str.lower
return sorted(seq, key)
....would much appreciate any guidance!