Skip to content

Commit

Permalink
Working on new sorting option
Browse files Browse the repository at this point in the history
  • Loading branch information
FenPhoenix committed May 19, 2019
1 parent 67ffcc2 commit c8e84eb
Showing 1 changed file with 47 additions and 13 deletions.
60 changes: 47 additions & 13 deletions AngelLoader/Common/Comparers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,28 @@ internal sealed class FMRatingComparer : IComparer<FanMission>

public int Compare(FanMission x, FanMission y)
{
int ret =
x == null || y == null ? 0 :
x.Rating == y.Rating ? TitleCompare(x, y) :
x.Rating == 0 ? -1 :
y.Rating == 0 ? 1 :
x.Rating < y.Rating ? -1 : 1;
int ret;
// Working
if (false)
{
int one = _sortOrder == SortOrder.Ascending ? 1 : -1;

ret =
x == null || y == null ? 0 :
x.Rating == y.Rating ? TitleCompare(x, y) :
x.Rating == -1 && y.Rating > -1 ? one :
x.Rating > -1 && y.Rating == -1 ? -one :
x.Rating > -1 && y.Rating > -1 && x.Rating < y.Rating ? -1 : 1;
}
else
{
ret =
x == null || y == null ? 0 :
x.Rating == y.Rating ? TitleCompare(x, y) :
x.Rating == 0 ? -1 :
y.Rating == 0 ? 1 :
x.Rating < y.Rating ? -1 : 1;
}

return _sortOrder == SortOrder.Ascending ? ret : -ret;
}
Expand All @@ -210,13 +226,31 @@ internal sealed class FMFinishedComparer : IComparer<FanMission>

public int Compare(FanMission x, FanMission y)
{
int ret =
x == null || y == null ? 0 :
!x.FinishedOnUnknown && y.FinishedOnUnknown ? -1 :
x.FinishedOnUnknown && !y.FinishedOnUnknown ? 1 :
(x.FinishedOnUnknown && y.FinishedOnUnknown) || x.FinishedOn == y.FinishedOn
? TitleCompare(x, y) :
x.FinishedOn < y.FinishedOn ? -1 : 1;
int ret;
// Working: will add new option for this when done
if (false)
{
ret =
x == null || y == null ? 0 :
(x.FinishedOnUnknown && y.FinishedOnUnknown) || x.FinishedOn == y.FinishedOn
? TitleCompare(x, y) :
!x.FinishedOnUnknown && y.FinishedOnUnknown ? -1 :
x.FinishedOnUnknown && !y.FinishedOnUnknown ? 1 :
x.FinishedOn == 0 && y.FinishedOn > 0 ? 1 :
x.FinishedOn > 0 && y.FinishedOn == 0 ? -1 :
x.FinishedOn > 0 && y.FinishedOn > 0 && x.FinishedOn < y.FinishedOn ? -1 : 1;
}
else
{
ret =
x == null || y == null ? 0 :
!x.FinishedOnUnknown && y.FinishedOnUnknown ? -1 :
x.FinishedOnUnknown && !y.FinishedOnUnknown ? 1 :
(x.FinishedOnUnknown && y.FinishedOnUnknown) || x.FinishedOn == y.FinishedOn
? TitleCompare(x, y) :
x.FinishedOn < y.FinishedOn ? -1 : 1;
}


return _sortOrder == SortOrder.Ascending ? ret : -ret;
}
Expand Down

0 comments on commit c8e84eb

Please sign in to comment.