From 8ae2dcecc765df1a98a5dc686473ac46f5e08c3e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 18 Dec 2018 22:17:36 +0000 Subject: [PATCH] swaroop: alphabetically sort playlists. --- src/wx/swaroop_controls.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc index 5e386ae9b..176efc443 100644 --- a/src/wx/swaroop_controls.cc +++ b/src/wx/swaroop_controls.cc @@ -34,6 +34,7 @@ using std::string; using std::cout; using std::exception; +using std::sort; using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::optional; @@ -271,6 +272,13 @@ SwaroopControls::add_playlist_to_list (SPL spl) _spl_view->InsertItem (it); } +struct SPLComparator +{ + bool operator() (SPL const & a, SPL const & b) { + return a.name() < b.name(); + } +}; + void SwaroopControls::update_playlist_directory () { @@ -290,12 +298,18 @@ SwaroopControls::update_playlist_directory () SPL spl; spl.read (i->path(), _content_view); _playlists.push_back (spl); - add_playlist_to_list (spl); } } catch (exception& e) { /* Never mind */ } } + + sort (_playlists.begin(), _playlists.end(), SPLComparator()); + for (SPL i: _playlists) { + add_playlist_to_list (i); + } + + _selected_playlist = boost::none; } void -- 2.30.2