2024-01-23 17:43:25 +00:00
|
|
|
namespace Mixonomer.Playlist.Sort;
|
|
|
|
|
|
|
|
public static class SortExtensions
|
|
|
|
{
|
|
|
|
private static Random _rng = new Random();
|
|
|
|
|
|
|
|
public static IOrderedEnumerable<CommonTrack> OrderByArtistAlbumTrackNumber(this IEnumerable<CommonTrack> input) =>
|
2024-06-14 08:07:56 +01:00
|
|
|
input.OrderBy(x => x.AlbumArtistNames.FirstOrDefault())
|
2024-01-23 17:43:25 +00:00
|
|
|
.ThenBy(x => x.AlbumName)
|
|
|
|
.ThenBy(x => x.DiscNumber)
|
|
|
|
.ThenBy(x => x.TrackNumber);
|
|
|
|
|
|
|
|
public static IOrderedEnumerable<CommonTrack> OrderByReleaseDate(this IEnumerable<CommonTrack> input) =>
|
2024-06-14 07:23:25 +01:00
|
|
|
input.OrderByDescending(x => x.ReleaseDate)
|
2024-06-14 08:07:56 +01:00
|
|
|
.ThenBy(x => x.AlbumArtistNames.FirstOrDefault())
|
2024-06-14 07:23:25 +01:00
|
|
|
.ThenBy(x => x.AlbumName)
|
|
|
|
.ThenBy(x => x.DiscNumber)
|
|
|
|
.ThenBy(x => x.TrackNumber);
|
2024-01-23 17:43:25 +00:00
|
|
|
|
|
|
|
public static IOrderedEnumerable<CommonTrack> Shuffle(this IEnumerable<CommonTrack> input) =>
|
|
|
|
input.OrderBy(x => _rng.Next());
|
|
|
|
}
|