From d071c098229f5523e1a395e2fe173952ecde08d2 Mon Sep 17 00:00:00 2001 From: xenofem Date: Tue, 2 Apr 2024 14:05:38 -0400 Subject: [PATCH] case insensitive sorting of categories --- dlibrary/dlibrary.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index 6baf32f..7bce8b9 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -1154,7 +1154,7 @@ def generate(args): def make_categorization(categorization, query, work_filter, work_style_cards=False): categorization_dir = site_dir / categorization - cats = [cat for (cat,) in cur.execute(query)] + cats = sorted((cat for (cat,) in cur.execute(query)), key=str.casefold) cat_samples = {} for cat in cats: cat_works = list(filter(work_filter(cat), works)) @@ -1183,22 +1183,22 @@ def generate(args): make_categorization( 'authors', - 'SELECT DISTINCT author FROM authors ORDER BY author', + 'SELECT DISTINCT author FROM authors', lambda author: lambda work: author in work['authors'], ) make_categorization( 'tags', - 'SELECT DISTINCT tag FROM tags ORDER BY tag', + 'SELECT DISTINCT tag FROM tags', lambda tag: lambda work: tag in work['tags'], ) make_categorization( 'circles', - 'SELECT DISTINCT circle FROM works WHERE circle NOT NULL ORDER BY circle', + 'SELECT DISTINCT circle FROM works WHERE circle NOT NULL', lambda circle: lambda work: work['circle'] == circle, ) make_categorization( 'series', - 'SELECT DISTINCT series FROM works WHERE series NOT NULL ORDER BY series', + 'SELECT DISTINCT series FROM works WHERE series NOT NULL', lambda series: lambda work: work['series'] == series, work_style_cards=True, )