Index: Slim/Schema/ResultSet/Contributor.pm =================================================================== --- Slim/Schema/ResultSet/Contributor.pm (revision 10665) +++ Slim/Schema/ResultSet/Contributor.pm (working copy) @@ -7,6 +7,29 @@ use Slim::Utils::Prefs; +my @albumSortRules = ( + # 0: No special sorting + "concat('0', album.titlesort), album.disc", + + # 1: Sort by year ascending, unset years last + "CASE album.year " . + " WHEN 0 THEN 9999" . + " ELSE album.year " . + "END, concat('0', album.titlesort), album.disc", + + # 2: Sort by year ascending, unset years first + "album.year, concat('0', album.titlesort), album.disc", + + # 3: Sort by year descending, unset years last + "album.year DESC, concat('0', album.titlesort), album.disc", + + # 4: Sort by year ascending, unset years first + "CASE album.year " . + " WHEN 0 THEN 9999" . + " ELSE album.year " . + "END DESC, concat('0', album.titlesort), album.disc" +); + sub pageBarResults { my $self = shift; @@ -112,7 +135,8 @@ } else { - $sort = "concat('0', album.titlesort), album.disc"; + my $sortByYear = Slim::Utils::Prefs::get('sortAlbumsByYear') || 0; + $sort = $albumSortRules[$sortByYear] || $albumSortRules[0]; } my $attr = { Index: Slim/Utils/Prefs.pm =================================================================== --- Slim/Utils/Prefs.pm (revision 10665) +++ Slim/Utils/Prefs.pm (working copy) @@ -171,6 +171,7 @@ 'longdateFormat' => q(%A, %B |%d, %Y), 'shortdateFormat' => q(%m/%d/%Y), 'showYear' => 0, + 'sortAlbumsByYear' => 0, 'timeFormat' => q(|%I:%M:%S %p), 'titleFormatWeb' => 1, 'ignoreDirRE' => '', Index: Slim/Web/Settings/Server/TextFormatting.pm =================================================================== --- Slim/Web/Settings/Server/TextFormatting.pm (revision 10665) +++ Slim/Web/Settings/Server/TextFormatting.pm (working copy) @@ -30,6 +30,7 @@ timeFormat showArtist showYear + sortAlbumsByYear ); # If this is a settings update Index: HTML/EN/settings/server/formatting.html =================================================================== --- HTML/EN/settings/server/formatting.html (revision 10665) +++ HTML/EN/settings/server/formatting.html (working copy) @@ -61,6 +61,19 @@ +