ui: sort by number if all values are numeric

This commit is contained in:
Vinícius 2022-01-17 14:27:53 -03:00 committed by Peter F. Patel-Schneider
parent d2f44299f3
commit 2eb6864cfb
1 changed files with 2 additions and 1 deletions

View File

@ -1544,7 +1544,8 @@ class SetValueControl(Gtk.HBox):
def make_choice(self, values):
self._hide_all()
self.choice_widget.remove_all()
for v in sorted(values, key=str):
sort_key = int if all(str(v).isdigit() for v in values) else str
for v in sorted(values, key=sort_key):
self.choice_widget.append(str(int(v)), str(v))
CompletionEntry.add_completion_to_entry(self.choice_widget.get_child(), map(str, values))
self.choice_widget._allowed_values = values