media library: sort track numbers as integers, not strings

This commit is contained in:
Andrzej Rybczak
2015-08-13 10:46:12 +02:00
parent c8ee598e0c
commit 8f9a1a8fc0
2 changed files with 8 additions and 1 deletions

1
NEWS
View File

@@ -27,6 +27,7 @@ ncmpcpp-0.7 (????-??-??)
* Sorting actions were rebound to Ctrl-S.
* Support for range selection was added (bound to Ctrl-V by default). In addition, sorting, reversing and shuffling items in playlist now works on ranges.
* Support for selecting found items was added (bound to Ctrl-_ by default).
* Tracks in media library are now properly sorted for track numbers greater than 99.
ncmpcpp-0.6.5 (2015-07-05)

View File

@@ -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();
}
}
};