Skip to content

Commit

Permalink
Simplify code for reversible sorter
Browse files Browse the repository at this point in the history
Thanks to @SqAtx for the suggestion
  • Loading branch information
diegogangl committed Sep 15, 2024
1 parent ff566ec commit 8a8d749
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions GTG/core/sorters.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ def reverse(self, value: bool) -> None:
def reversible_compare(self, first, second) -> Gtk.Ordering:
"""Compare for reversible sorters."""

if self._reverse:
if first < second:
if first == second:
return Gtk.Ordering.EQUAL

if first < second:
if self._reverse:
return Gtk.Ordering.LARGER
elif first > second:
return Gtk.Ordering.SMALLER
else:
return Gtk.Ordering.EQUAL
else:
if first > second:
return Gtk.Ordering.LARGER
elif first < second:
return Gtk.Ordering.SMALLER
else:
return Gtk.Ordering.EQUAL

if self._reverse:
return Gtk.Ordering.SMALLER
else:
return Gtk.Ordering.LARGER


class TaskTitleSorter(ReversibleSorter):
Expand Down

0 comments on commit 8a8d749

Please sign in to comment.