From 8a24aa89b39d653805433085c49e5c12df96d299 Mon Sep 17 00:00:00 2001 From: Davide Setti Date: Thu, 18 Nov 2010 23:36:38 +0800 Subject: [PATCH] use itemgetter() in sort() instead of a lambda function --- autojump | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autojump b/autojump index ec9b7dd..3195d0e 100755 --- a/autojump +++ b/autojump @@ -25,6 +25,7 @@ except ImportError: import getopt from sys import argv,exit,stderr,version_info from tempfile import NamedTemporaryFile +from operator import itemgetter import os import signal max_keyweight=1000 @@ -135,7 +136,7 @@ if ('-a','') in optlist: save(path_dict,dic_file) elif ('--stat','') in optlist: a=list(path_dict.items()) - a.sort(key=lambda e:e[1]) + a.sort(key=itemgetter(1)) for path,count in a[-100:]: print("%.1f:\t%s" % (count,path)) print("Total key weight: %d. Number of stored paths: %d" % (sum(path_dict.values()),len(a))) @@ -172,7 +173,7 @@ else: if endmatch: patterns[-1]=endmatch.group(1) dirs=list(path_dict.items()) - dirs.sort(key=lambda e:e[1],reverse=True) + dirs.sort(key=itemgetter(1), reverse=True) if completion or userchoice != -1: max_matches = 9 else: