Transform cmp to key functions (pattern.db)
@@ -30,6 +30,8 @@ from types import GeneratorType
from builtins import range
from past.builtins import basestring, unicode
+from functools import cmp_to_key
+
try: # Python 2.x vs 3.x
from cStringIO import StringIO
except ImportError:
@@ -470,7 +472,7 @@ def order(list, cmp=None, key=None, reverse=False):
f = lambda i, j: int(key(list[i]) >= key(list[j])) * 2 - 1
else:
f = lambda i, j: int(list[i] >= list[j]) * 2 - 1
- return sorted(range(len(list)), cmp=f, reverse=reverse)
+ return sorted(range(len(list)), key=cmp_to_key(f), reverse=reverse)
_order = order
