Skip to content

Commit

Permalink
sort choices to make it easier to select
Browse files Browse the repository at this point in the history
The sorting is applied to both standard and GMT choices.
  • Loading branch information
hrbonz committed Jan 13, 2024
1 parent 4207dc0 commit 1b5a399
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timezone_field/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def standard(timezones):
for tz in timezones:
tz_str = str(tz)
choices.append((tz, tz_str.replace("_", " ")))
return choices
return sorted(choices, key=lambda tup: tup[1])


def with_gmt_offset(timezones, now=None, use_pytz=None):
Expand All @@ -41,4 +41,4 @@ def with_gmt_offset(timezones, now=None, use_pytz=None):
_choices.append((delta, tz, display))
_choices.sort(key=lambda x: x[0])
choices = [(one, two) for zero, one, two in _choices]
return choices
return sorted(choices, key=lambda tup: tup[1])

0 comments on commit 1b5a399

Please sign in to comment.