sepolgen: Use sort function with key parameter.

Since Python 2.4 .sort() as well as the new sorted() function
take a key parameter which should be a function that returns
a sorting key.

Signed-off-by: Robert Kuska <rkuska@redhat.com>
This commit is contained in:
Robert Kuska 2015-07-16 13:48:14 +02:00 committed by Stephen Smalley
parent 467c2a45b9
commit 788f5dba54
2 changed files with 3 additions and 3 deletions

View File

@ -635,11 +635,11 @@ def lex(module=None,object=None,debug=0,optimize=0,lextab="lextab",reflags=0,now
# Sort the functions by line number
for f in funcsym.values():
f.sort(lambda x,y: cmp(x[1].__code__.co_firstlineno,y[1].__code__.co_firstlineno))
f.sort(key=lambda x: x[1].__code__.co_firstlineno)
# Sort the strings by regular expression length
for s in strsym.values():
s.sort(lambda x,y: (len(x[1]) < len(y[1])) - (len(x[1]) > len(y[1])))
s.sort(key=lambda x: len(x[1]))
regexs = { }

View File

@ -2100,7 +2100,7 @@ def yacc(method=default_lr, debug=yaccdebug, module=None, tabmodule=tab_module,
raise YaccError,"no rules of the form p_rulename are defined."
# Sort the symbols by line number
symbols.sort(lambda x,y: cmp(x.__code__.co_firstlineno,y.__code__.co_firstlineno))
symbols.sort(key=lambda x: x.__code__.co_firstlineno)
# Add all of the symbols to the grammar
for f in symbols: