diff --git a/server/szurubooru/func/tags.py b/server/szurubooru/func/tags.py index 19f338a7..e92440cd 100644 --- a/server/szurubooru/func/tags.py +++ b/server/szurubooru/func/tags.py @@ -63,7 +63,7 @@ def sort_tags(tags): return sorted( tags, key=lambda tag: ( - default_category_name != tag.category.name, + default_category_name == tag.category.name, tag.category.name, tag.names[0].name) ) diff --git a/server/szurubooru/tests/func/test_tags.py b/server/szurubooru/tests/func/test_tags.py index 07c6723e..061639c7 100644 --- a/server/szurubooru/tests/func/test_tags.py +++ b/server/szurubooru/tests/func/test_tags.py @@ -19,10 +19,10 @@ def _assert_tag_siblings(result, expected_names_and_occurrences): @pytest.mark.parametrize('input,expected_tag_names', [ - ([('a', 'a', True), ('b', 'b', False), ('c', 'c', False)], list('abc')), - ([('c', 'a', True), ('b', 'b', False), ('a', 'c', False)], list('cba')), - ([('a', 'c', True), ('b', 'b', False), ('c', 'a', False)], list('acb')), - ([('a', 'c', False), ('b', 'b', False), ('c', 'a', True)], list('cba')), + ([('a', 'a', True), ('b', 'b', False), ('c', 'c', False)], list('bca')), + ([('c', 'a', True), ('b', 'b', False), ('a', 'c', False)], list('bac')), + ([('a', 'c', True), ('b', 'b', False), ('c', 'a', False)], list('cba')), + ([('a', 'c', False), ('b', 'b', False), ('c', 'a', True)], list('bac')), ]) def test_sort_tags( input, expected_tag_names, tag_factory, tag_category_factory):