]> granicus.if.org Git - python/commitdiff
Convert some custom sort comparison functions to equivalent key functions.
authorKurt B. Kaiser <kbk@shore.net>
Tue, 12 Feb 2008 21:34:12 +0000 (21:34 +0000)
committerKurt B. Kaiser <kbk@shore.net>
Tue, 12 Feb 2008 21:34:12 +0000 (21:34 +0000)
Lib/idlelib/configDialog.py
Lib/idlelib/configHandler.py

index e7a06909cb5375aafebdfe6de4cd10c9880211aa..d0e4066b295cc45d4fc6dd6707b3ae5e5176915c 100644 (file)
@@ -980,16 +980,11 @@ class ConfigDialog(Toplevel):
         self.SetThemeType()
         ##load theme element option menu
         themeNames = list(self.themeElements.keys())
-        themeNames.sort(self.__ThemeNameIndexCompare)
+        themeNames.sort(key=lambda x: self.themeElements[x][1])
         self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
         self.PaintThemeSample()
         self.SetHighlightTarget()
 
-    def __ThemeNameIndexCompare(self,a,b):
-        if self.themeElements[a][1]<self.themeElements[b][1]: return -1
-        elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
-        else: return 1
-
     def LoadKeyCfg(self):
         ##current keys type radiobutton
         self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',
index 66bad74bf0b3046f6ece13e14d6f0edd1b35e9f4..9c106eb1d170b11a395e289797d4caf3260a58db 100644 (file)
@@ -642,17 +642,9 @@ class IdleConf:
                 helpPath=value[1].strip()
             if menuItem and helpPath: #neither are empty strings
                 helpSources.append( (menuItem,helpPath,option) )
-        helpSources.sort(self.__helpsort)
+        helpSources.sort(key=lambda x: x[2])
         return helpSources
 
-    def __helpsort(self, h1, h2):
-        if int(h1[2]) < int(h2[2]):
-            return -1
-        elif int(h1[2]) > int(h2[2]):
-            return 1
-        else:
-            return 0
-
     def GetAllExtraHelpSourcesList(self):
         """
         Returns a list of tuples containing the details of all additional help