Make sort() use key= rather than cmp. All regression tests pass.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 23 Feb 2012 16:59:16 +0000 (11:59 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 23 Feb 2012 16:59:33 +0000 (11:59 -0500)
sst.py

diff --git a/sst.py b/sst.py
index 0ef0f092018d5931580923ece5694c1580ac6915..7ca6caa3dbc69670078ffa7b4d627bd27d9d274b 100755 (executable)
--- a/sst.py
+++ b/sst.py
@@ -745,7 +745,7 @@ def supercommander():
         for (i, base) in enumerate(game.state.baseq):
             basetbl.append((i, (base - sc).distance()))
         if game.state.baseq > 1:
-            basetbl.sort(lambda x, y: cmp(x[1], y[1]))
+            basetbl.sort(key=lambda x: x[1])
         # look for nearest base without a commander, no Enterprise, and
         # without too many Klingons, and not already under attack. 
         ifindit = iwhichb = 0
@@ -5734,7 +5734,7 @@ def newkling():
 
 def sortenemies():
     "Sort enemies by distance so 'nearest' is meaningful."
-    game.enemies.sort(lambda x, y: cmp(x.kdist, y.kdist))
+    game.enemies.sort(key=lambda x: x.kdist)
 
 def newqad():
     "Set up a new state of quadrant, for when we enter or re-enter it."