From cb788a75c8d06d2bad335e175c27dc450906ba8b Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Thu, 14 Jul 2016 21:58:48 +0000 Subject: [PATCH] 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). --- quixote/form/widget.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/quixote/form/widget.py b/quixote/form/widget.py index 857905e..5528a34 100644 --- a/quixote/form/widget.py +++ b/quixote/form/widget.py @@ -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):