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
This commit is contained in:
@@ -1026,7 +1026,7 @@ def series_list():
|
||||
.count())
|
||||
if no_series_count:
|
||||
entries.append([db.Category(_("None"), "-1"), no_series_count])
|
||||
entries = sorted(entries, key=lambda x: x[0].name.lower(), reverse=not order_no)
|
||||
entries = sorted(entries, key=lambda x: (x[0].sort or x[0].name).lower(), reverse=not order_no)
|
||||
return render_title_template('list.html',
|
||||
entries=entries,
|
||||
folder='web.books_list',
|
||||
|
||||
Reference in New Issue
Block a user