this is useful if we want to be able to use operators on our objects howeverif all we want to do is customize our sort orderseven this is overkill for such use casethe sort method can take an optional key argument this argument is function that can translate each object in list into an object that can somehow be compared for examplewe can use str lower as the key argument to perform case-insensitive sort on list of stringsl ["hello""help""helo" sort( ['help''helo''hello' sort(key=str lowerl ['hello''helo''help'remembereven though lower is method on string objectsit is also function that can accept single argumentself in other wordsstr lower(itemis equivalent to item lower(when we pass this function as keyit performs the comparison on lowercase values instead of doing the default case-sensitive comparison there are few sort key operations that are so common that the python team has supplied them so you don' have to write them yourself for exampleit is often common to sort list of tuples by something other than the first item in the list the operator itemgetter method can be used as key to do thisfrom operator import itemgetter [(' ' )(' ' )(' ' )(' ' )(' ' )(' ' ) sort(key=itemgetter( ) [(' ' )(' ' )(' ' )(' ' )(' ' )(' ' )the itemgetter function is the most commonly used one (it works if the objects are dictionariestoo)but you will sometimes find use for attrgetter and methodcallerwhich return attributes on an object and the results of method calls on objects for the same purpose see the operator module documentation for more information