03-04-2009, 08:42 AM | #1 |
Groupie
Posts: 168
Karma: 2584958
Join Date: Jan 2009
Location: Texas
Device: Kindle PW2
|
Question about Column Sorting
Hello,
I've just started using Calibre and am simply amazed at how good it is. I have a hopefully simple question about column sorting. I have the following column Layout: Author Series Title Currently, I can sort by one column only. So while I can make the author's appear in alpha order, then the series column seems fairly random. Is there a way to sort by Multiple columns so I can have authors as first priority, then it sorts series within the authors and then by volume number? Thanks! Danny |
03-04-2009, 09:58 AM | #2 |
Chocolate Grasshopper ...
Posts: 27,600
Karma: 20821184
Join Date: Mar 2008
Location: Scotland
Device: Muse HD , Cybook Gen3 , Pocketbook 302 (Black) , Nexus 10: wife has PW
|
Welcome Danny, there will be an expert along shortly ....
|
Advert | |
|
03-04-2009, 11:13 AM | #3 |
Enthusiast
Posts: 32
Karma: 10
Join Date: Sep 2007
Device: Android phone + PRS-505
|
I looked at the sorting code in database2.py, and it is always forcing the same secondary sort key if the entries in the requested sort column are the same. This apears to be the "path" data, which essentially gives you a sub-sort of the book title if the author is the same, or author if the title is the same, etc.
What I'd prefer to see is the sort function being allowed to return 0 when items are the same. Because python has a stable sort (one that keeps the current order when the sort term is found to be equal), this would let you choose your sub-sort by whatever column you had clicked previously. If you are comfortable editing source, this is as easy as editing the src/calibre/library/database2.py file, looking for the "def sort" function, commenting out the last 2 lines, and adding "return ans" to the end. The last 3 lines would then look like this: Code:
#if ans != 0: return ans #return cmp(self._data[x][11].lower(), self._data[y][11].lower()) return ans |
03-04-2009, 12:47 PM | #4 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
will be in next release
|
03-04-2009, 02:23 PM | #5 |
Wizard
Posts: 1,229
Karma: 543210
Join Date: Feb 2008
Location: Gatlinburg, Tennessee
Device: Kindles: Paperwhite Signature Ed., Oasis 2, Voyage
|
|
Advert | |
|
03-04-2009, 03:24 PM | #6 |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
|
03-05-2009, 04:48 AM | #7 |
Groupie
Posts: 168
Karma: 2584958
Join Date: Jan 2009
Location: Texas
Device: Kindle PW2
|
Excellent!
|
03-05-2009, 10:33 AM | #8 |
Enthusiast
Posts: 32
Karma: 10
Join Date: Sep 2007
Device: Android phone + PRS-505
|
one more tweak for the startup
One thing I thought of was that at startup time, we need to do two sorts in order to ensure that the user gets a nice sort order for something like author. The best solution is probably be to remember two most recent sorts the user did and rerun them both when refreshing the book list. Another is to do an initial sort by path and then apply the remembered sort (since that at least gets a remembered author sort to sub-sort by title instead of coming up in whatever order the DB returned the entries).
Code:
--- src/calibre/library/database2.py 2009-03-04 17:46:47 +0000
+++ src/calibre/library/database2.py 2009-03-05 15:21:33 +0000
@@ -256,6 +256,7 @@
for r in temp:
self._data[r[0]] = r
self._map = [i[0] for i in self._data if i is not None]
+ self.sort('path', ascending)
if field is not None:
self.sort(field, ascending)
self._map_filtered = list(self._map)
|
03-05-2009, 11:59 AM | #9 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Doing a double sort on startup would be a major performance hit for people with large libraries. Instead I'll simply have restore the previous behavior for the first sort.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
2 column PDF book to 1 column possible? | SeaBookGuy | Calibre | 19 | 07-01-2013 02:30 AM |
Q: multi-column PDF to single column mobi format converstion | auburn1975 | Calibre | 7 | 01-28-2012 06:11 PM |
Question re: sorting by author | osirisomeomi | Calibre | 8 | 04-14-2010 03:43 PM |
Question about sorting on the 360 | askyn | PocketBook | 6 | 04-05-2010 07:57 PM |
pdf to lrf with 2 column and 1 column pages in same file | danielwille | Sony Reader | 3 | 11-12-2008 10:57 AM |