Skip to content

Commit 1134f54

Browse files
fix: series list view sorts by name instead of sort field
In series_list(), the SQLite query correctly orders results by Series.sort, but a subsequent Python sorted() call (needed to re-order after appending the "None" category entry) was using Series.name as the sort key instead of Series.sort. This caused series titles with leading articles (A, An, The) to sort strictly alphabetically by the article rather than by the meaningful word, e.g. "A Collins-Burke Mystery" appeared under "A" instead of "C". Fix by using Series.sort (with a fallback to Series.name if sort is NULL) as the key in the Python re-sort, consistent with the intent of the existing DB query. Fixes #3583
1 parent 6157f50 commit 1134f54

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cps/web.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ def series_list():
10261026
.count())
10271027
if no_series_count:
10281028
entries.append([db.Category(_("None"), "-1"), no_series_count])
1029-
entries = sorted(entries, key=lambda x: x[0].name.lower(), reverse=not order_no)
1029+
entries = sorted(entries, key=lambda x: (x[0].sort or x[0].name).lower(), reverse=not order_no)
10301030
return render_title_template('list.html',
10311031
entries=entries,
10321032
folder='web.books_list',

0 commit comments

Comments
 (0)