Fix 'unorderable type' error in Python 3