mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 00:53:19 +08:00
Simplify sorting logic
This commit is contained in:
parent
385bc6f529
commit
9223a1ba8a
@ -16,6 +16,7 @@ using osu.Game.Overlays.SearchableList;
|
||||
using osu.Game.Overlays.Social;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Threading;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -188,31 +189,11 @@ namespace osu.Game.Overlays
|
||||
switch (Filter.Tabs.Current.Value)
|
||||
{
|
||||
case SocialSortCriteria.Location:
|
||||
switch (sortDirection)
|
||||
{
|
||||
case SortDirection.Ascending:
|
||||
sortedUsers = sortedUsers.OrderBy(u => u.Country.FullName);
|
||||
break;
|
||||
|
||||
case SortDirection.Descending:
|
||||
sortedUsers = sortedUsers.OrderByDescending(u => u.Country.FullName);
|
||||
break;
|
||||
}
|
||||
|
||||
sortedUsers = sortBy(sortedUsers, u => u.Country.FullName, sortDirection);
|
||||
break;
|
||||
|
||||
case SocialSortCriteria.Name:
|
||||
switch (sortDirection)
|
||||
{
|
||||
case SortDirection.Ascending:
|
||||
sortedUsers = sortedUsers.OrderBy(u => u.Username);
|
||||
break;
|
||||
|
||||
case SortDirection.Descending:
|
||||
sortedUsers = sortedUsers.OrderByDescending(u => u.Username);
|
||||
break;
|
||||
}
|
||||
|
||||
sortedUsers = sortBy(sortedUsers, u => u.Username, sortDirection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -221,6 +202,9 @@ namespace osu.Game.Overlays
|
||||
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
|
||||
}
|
||||
|
||||
private IEnumerable<User> sortBy<T>(IEnumerable<User> users, Func<User, T> condition, SortDirection sortDirection) =>
|
||||
sortDirection == SortDirection.Ascending ? users.OrderBy(condition) : users.OrderByDescending(condition);
|
||||
|
||||
private void onDropdownChanged()
|
||||
{
|
||||
if (Users == null)
|
||||
|
Loading…
Reference in New Issue
Block a user