From 2f488b767c02584667edb69375c5ad2948811c4b Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Sun, 30 Sep 2012 19:45:39 +0200 Subject: [PATCH] Improved home page sorting for artists with an unknown number of total tracks by sorting by the number of Tracks we have after sorting by the percentage --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index e33801e6..2093f010 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -465,7 +465,7 @@ class WebInterface(object): totalcount = myDB.select('SELECT COUNT(*) from artists')[0][0] if sortbyhavepercent: - filtered.sort(key=lambda x:float(x['HaveTracks'])/x['TotalTracks'] if x['TotalTracks'] > 0 else 0.0,reverse=sSortDir_0 == "asc") + filtered.sort(key=lambda x:(float(x['HaveTracks'])/x['TotalTracks'] if x['TotalTracks'] > 0 else 0.0,x['HaveTracks'] if x['HaveTracks'] else 0.0),reverse=sSortDir_0 == "asc") #can't figure out how to change the datatables default sorting order when its using an ajax datasource so ill #just reverse it here and the first click on the "Latest Album" header will sort by descending release date