Fix arbitrary sorting by "Favorite" in the UI by making it the same as sorting alphabetically while giving favorites priority.

This commit is contained in:
Logan Stromberg 2024-08-06 11:10:55 -07:00
parent 7969fb6bba
commit ffee98889e

View file

@ -965,8 +965,10 @@ namespace Ryujinx.Ava.UI.ViewModels
: SortExpressionComparer<ApplicationData>.Descending(app => app.FileSize),
ApplicationSort.Path => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Path)
: SortExpressionComparer<ApplicationData>.Descending(app => app.Path),
ApplicationSort.Favorite => !IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Favorite)
: SortExpressionComparer<ApplicationData>.Descending(app => app.Favorite),
// Favorite behaves same as sort by name except give favorited apps special ordering by prepending a space
// The intent is to return a block of favorited apps in alphabetical order, followed by all other apps in alphabetical order.
ApplicationSort.Favorite => IsAscending ? SortExpressionComparer<ApplicationData>.Ascending(app => app.Favorite ? ' ' + app.Name : app.Name)
: SortExpressionComparer<ApplicationData>.Descending(app => app.Favorite ? ' ' + app.Name : app.Name),
_ => null,
#pragma warning restore IDE0055
};