'c', 'D'] >>> list(unique('ABBcCAD', str.casefold, reverse=True)) ['D', 'c', 'B', 'A'] The elements in *iterable* need not be hashable, but they must be comparable for sorting to work. )