summaryrefslogtreecommitdiff
path: root/src/media_library.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2015-08-13 10:46:12 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2015-08-13 10:46:12 +0200
commit8f9a1a8fc0a8cdf108216a3e51a76f42d691cf18 (patch)
tree17103e4e3c6ea680841f4ac2460bdae93ea4b417 /src/media_library.cpp
parentc8ee598e0c46d4b8b06ee2aac1cde74fcbfd7000 (diff)
media library: sort track numbers as integers, not strings
Diffstat (limited to 'src/media_library.cpp')
-rw-r--r--src/media_library.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/media_library.cpp b/src/media_library.cpp
index ea630ad1..7e5fba12 100644
--- a/src/media_library.cpp
+++ b/src/media_library.cpp
@@ -106,7 +106,13 @@ public:
if (ret != 0)
return ret < 0;
}
- return a.getTrack() < b.getTrack();
+ try {
+ int ret = boost::lexical_cast<int>(a.getTags(&MPD::Song::getTrackNumber))
+ - boost::lexical_cast<int>(b.getTags(&MPD::Song::getTrackNumber));
+ return ret < 0;
+ } catch (boost::bad_lexical_cast &) {
+ return a.getTrackNumber() < b.getTrackNumber();
+ }
}
};