From 4b48be4a5b213ea587baeda3c8489824d8dc781a Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Wed, 10 Dec 2014 22:43:16 +0100 Subject: [PATCH] Sort Grooveshark favorite songs according to "TSFavorited", as such songs have no "Sort" field. BTW the compare was buggy (didn't compare against song2). This was OK though, as we stable sort songs, and they are always ordered as far as I know (I remember adding this sort just in case they will not be sent ordered on day). --- src/internet/groovesharkservice.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/internet/groovesharkservice.cpp b/src/internet/groovesharkservice.cpp index 95b9b7ba8..dbe243587 100644 --- a/src/internet/groovesharkservice.cpp +++ b/src/internet/groovesharkservice.cpp @@ -1717,7 +1717,15 @@ QVariantMap GroovesharkService::ExtractResult(QNetworkReply* reply) { namespace { bool CompareSongs(const QVariant& song1, const QVariant& song2) { - return song1.toMap()["Sort"].toInt() < song1.toMap()["Sort"].toInt(); + QMap song1_map = song1.toMap(); + QMap song2_map = song2.toMap(); + int song1_sort = song1_map["Sort"].toInt(); + int song2_sort = song2_map["Sort"].toInt(); + if (song1_sort == song2_sort) { + // Favorite songs have a "TSFavorited" and (currently) no "Sort" field + return song1_map["TSFavorited"].toString() < song2_map["TSFavorited"].toString(); + } + return song1_sort < song2_sort; } }