Convert some custom sort comparison functions to equivalent key functions.
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
index 56b4e3a..563390b 100644
--- a/Lib/bsddb/dbtables.py
+++ b/Lib/bsddb/dbtables.py
@@ -88,6 +88,15 @@
     def __call__(self, s):
         return self.re.match(s.decode(self.encoding))
 
+def CmpToKey(mycmp):
+    'Convert a cmp= function into a key= function'
+    class K(object):
+        def __init__(self, obj, *args):
+            self.obj = obj
+        def __lt__(self, other):
+            return mycmp(self.obj, other.obj) == -1
+    return K
+
 #
 # keys used to store database metadata
 #
@@ -587,7 +596,7 @@
             return 0
 
         conditionlist = list(conditions.items())
-        conditionlist.sort(cmp_conditions)
+        conditionlist.sort(key=CmpToKey(cmp_conditions))
 
         # Apply conditions to column data to find what we want
         cur = self.db.cursor()
diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py
index a36faae..49aa7ca 100644
--- a/Lib/bsddb/test/test_compare.py
+++ b/Lib/bsddb/test/test_compare.py
@@ -32,10 +32,20 @@
 _expected_lowercase_test_data = [s.encode('ascii') for s in
         ('', 'a', 'aaa', 'b', 'c', 'CC', 'cccce', 'ccccf', 'CCCP')]
 
+
+def CmpToKey(mycmp):
+    'Convert a cmp= function into a key= function'
+    class K(object):
+        def __init__(self, obj, *args):
+            self.obj = obj
+        def __lt__(self, other):
+            return mycmp(self.obj, other.obj) == -1
+    return K
+
 class ComparatorTests (unittest.TestCase):
     def comparator_test_helper (self, comparator, expected_data):
         data = expected_data[:]
-        data.sort (comparator)
+        data.sort (key=CmpToKey(comparator))
         self.failUnless (data == expected_data,
                          "comparator `%s' is not right: %s vs. %s"
                          % (comparator, expected_data, data))