Use sort(key=...) to sort widget options.

The decorate/undecorate pattern is no longer necessary and
can cause comparision errors in Python 3 (e.g. comparing distinct
types).
This commit is contained in:
Neil Schemenauer 2016-07-14 21:58:48 +00:00
parent 0e9b73be39
commit cb788a75c8
1 changed files with 3 additions and 4 deletions

View File

@ -404,11 +404,10 @@ class SelectWidget(Widget):
def make_sort_key(option):
value, description, key = option
if value is None:
return ('', option)
return ''
else:
return (stringify(description).lower(), option)
doptions = sorted(map(make_sort_key, options))
options = [item[1] for item in doptions]
return stringify(description).lower()
options.sort(key=make_sort_key)
self.options = options
def _parse_single_selection(self, parsed_key, default=None):