Let library modules use the new keyword arguments for list.sort().
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index f8e3fc5..d58bdc3 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -99,7 +99,7 @@
         except os.error:
             self.send_error(404, "No permission to list directory")
             return None
-        list.sort(lambda a, b: cmp(a.lower(), b.lower()))
+        list.sort(key=lambda a: a.lower())
         f = StringIO()
         f.write("<title>Directory listing for %s</title>\n" % self.path)
         f.write("<h2>Directory listing for %s</h2>\n" % self.path)
diff --git a/Lib/UserList.py b/Lib/UserList.py
index dd1b927..072f6a7 100644
--- a/Lib/UserList.py
+++ b/Lib/UserList.py
@@ -77,7 +77,7 @@
     def count(self, item): return self.data.count(item)
     def index(self, item, *args): return self.data.index(item, *args)
     def reverse(self): self.data.reverse()
-    def sort(self, *args): self.data.sort(*args)
+    def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
     def extend(self, other):
         if isinstance(other, UserList):
             self.data.extend(other.data)
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index 85db89d..4746544 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -52,7 +52,7 @@
 
     def __init__(self):
         """Set all attributes.
-        
+
         Order of methods called matters for dependency reasons.
 
         The locale language is set at the offset and then checked again before
@@ -68,7 +68,7 @@
         Only other possible issue is if someone changed the timezone and did
         not call tz.tzset .  That is an issue for the programmer, though,
         since changing the timezone is worthless without that call.
-        
+
         """
         self.lang = _getlang()
         self.__calc_weekday()
@@ -155,7 +155,7 @@
             date_time[offset] = current_format.replace('11', U_W)
         self.LC_date_time = date_time[0]
         self.LC_date = date_time[1]
-        self.LC_time = date_time[2] 
+        self.LC_time = date_time[2]
 
     def __calc_timezone(self):
         # Set self.timezone by using time.tzname.
@@ -178,9 +178,9 @@
 
     def __init__(self, locale_time=None):
         """Create keys/values.
-        
+
         Order of execution is important for dependency reasons.
-        
+
         """
         if locale_time:
             self.locale_time = locale_time
@@ -219,22 +219,20 @@
 
     def __seqToRE(self, to_convert, directive):
         """Convert a list to a regex string for matching a directive.
-        
+
         Want possible matching values to be from longest to shortest.  This
         prevents the possibility of a match occuring for a value that also
         a substring of a larger value that should have matched (e.g., 'abc'
         matching when 'abcdef' should have been the match).
-        
+
         """
         for value in to_convert:
             if value != '':
                 break
         else:
             return ''
-        to_sort = [(len(item), item) for item in to_convert]
-        to_sort.sort()
-        to_sort.reverse()
-        to_convert = [item for length, item in to_sort]
+        to_convert = to_convert[:]
+        to_convert.sort(key=len, reverse=True)
         regex = '|'.join(to_convert)
         regex = '(?P<%s>%s' % (directive, regex)
         return '%s)' % regex
diff --git a/Lib/difflib.py b/Lib/difflib.py
index a45c0bc..699845c 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -701,15 +701,11 @@
            s.quick_ratio() >= cutoff and \
            s.ratio() >= cutoff:
             result.append((s.ratio(), x))
-    # Sort by score.
-    result.sort()
-    # Retain only the best n.
-    result = result[-n:]
-    # Move best-scorer to head of list.
-    result.reverse()
-    # Strip scores.
-    return [x for score, x in result]
 
+    # Move the best scorers to head of list
+    result.sort(reverse=True)
+    # Strip scores for the best n matches
+    return [x for score, x in result[:n]]
 
 def _count_leading(line, ch):
     """
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 1f49bcb..4874904 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -553,7 +553,7 @@
 def walktree(classes, children, parent):
     """Recursive helper function for getclasstree()."""
     results = []
-    classes.sort(lambda a, b: cmp(a.__name__, b.__name__))
+    classes.sort(key=lambda c: c.__name__)
     for c in classes:
         results.append((c, c.__bases__))
         if c in children:
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index fee6342..8ccc203 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -779,7 +779,7 @@
             tag += ':<br>\n'
 
             # Sort attrs by name.
-            attrs.sort(lambda t1, t2: cmp(t1[0], t2[0]))
+            attrs.sort(key=lambda t: t[0])
 
             # Pump out the attrs, segregated by kind.
             attrs = spill('Methods %s' % tag, attrs,
diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py
index 07b24dd..fa009c1 100644
--- a/Lib/sre_constants.py
+++ b/Lib/sre_constants.py
@@ -219,7 +219,7 @@
     import string
     def dump(f, d, prefix):
         items = d.items()
-        items.sort(lambda a, b: cmp(a[1], b[1]))
+        items.sort(key=lambda a: a[1])
         for k, v in items:
             f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v))
     f = open("sre_constants.h", "w")