This is reproducible in a python3 shell. The problem is that sorted() is called on a list that includes both bytes and str types:
$ python3
Python 3.7.4 (default, Jul 11 2019, 10:43:21)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> blist=['1'.encode(), '3', '2'.encode()]
>>> sorted(blist)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'str' and 'bytes'
>>>
This is reproducible in a python3 shell. The problem is that sorted() is called on a list that includes both bytes and str types:
$ python3 '1'.encode( ), '3', '2'.encode()]
Python 3.7.4 (default, Jul 11 2019, 10:43:21)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> blist=[
>>> sorted(blist)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'str' and 'bytes'
>>>