From 277a1bad607acb06b3a6cf0ad031b34c744eb5df Mon Sep 17 00:00:00 2001 From: giomba Date: Sun, 21 Oct 2018 12:26:28 +0200 Subject: [PATCH] Return booklist ordered by title --- tcparser.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tcparser.py b/tcparser.py index b2d25ea..f9744a6 100644 --- a/tcparser.py +++ b/tcparser.py @@ -130,17 +130,18 @@ def getHTML(library): # Our nice XML/HTML tree return tree -# Filter results using following filter functions -################################################## +# Filter results using following filter functions and order by title +#################################################################### def filter(library, title='', author=''): - # print ("
" + json.dumps(library, indent=4) + "
") result = list() for i in library: if filterTitle(i, title) and filterAuthor(i, author): result.append(i) - return result + sortedResult = sorted(library, key=lambda k: k.get('title', '')) + + return sortedResult # Filter by title def filterTitle(book, filter):