From 0e3a2fc39d82fdb1d44e946f6ac33c3d22a9aa4b Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 4 Dec 2010 16:52:27 +0000 Subject: [PATCH] Better sorting in collection management --- src/calibre/devices/usbms/books.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/calibre/devices/usbms/books.py b/src/calibre/devices/usbms/books.py index 9e19e9c66d..e5a67463e7 100644 --- a/src/calibre/devices/usbms/books.py +++ b/src/calibre/devices/usbms/books.py @@ -216,14 +216,17 @@ class CollectionsBookList(BookList): elif is_series: if doing_dc: collections[cat_name][lpath] = \ - (book, book.get('series_index', sys.maxint), '') + (book, book.get('series_index', sys.maxint), + book.get('title_sort', 'zzzz')) else: collections[cat_name][lpath] = \ - (book, book.get(attr+'_index', sys.maxint), '') + (book, book.get(attr+'_index', sys.maxint), + book.get('title_sort', 'zzzz')) else: if lpath not in collections[cat_name]: collections[cat_name][lpath] = \ - (book, book.get('title_sort', 'zzzz'), '') + (book, book.get('title_sort', 'zzzz'), + book.get('title_sort', 'zzzz')) # Sort collections result = {} @@ -237,7 +240,7 @@ class CollectionsBookList(BookList): return 1 if y is None: return -1 - if isinstance(x, unicode): + if isinstance(x, (unicode, str)): c = cmp(sort_key(x), sort_key(y)) else: c = cmp(x, y)