Python 101 : Sorting a List as Strings or as Integers
We have for example the below list:
When we try to sort it, we get the above error, since the list is a mix of integers and strings.
We could remedy that using a key that will tell the sorted() function to sort the list considering all the elements as a unique type.
We could also sort our list considering all its elements as strings:
Comments