mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-16 01:55:27 +00:00
d536cc8ae6
`MB` and `GB` can either be interpreted as having base-10 units, or base-2. `MiB` and `GiB` removes this discrepancy so that units of memory are always interpreted using base-2 units.
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using Ryujinx.Ui.App.Common;
|
|
using System.Collections;
|
|
|
|
namespace Ryujinx.Ava.Ui.Models
|
|
{
|
|
internal class FileSizeSortComparer : IComparer
|
|
{
|
|
public int Compare(object x, object y)
|
|
{
|
|
string aValue = (x as ApplicationData).TimePlayed;
|
|
string bValue = (y as ApplicationData).TimePlayed;
|
|
|
|
if (aValue[^3..] == "GiB")
|
|
{
|
|
aValue = (float.Parse(aValue[0..^3]) * 1024).ToString();
|
|
}
|
|
else
|
|
{
|
|
aValue = aValue[0..^3];
|
|
}
|
|
|
|
if (bValue[^3..] == "GiB")
|
|
{
|
|
bValue = (float.Parse(bValue[0..^3]) * 1024).ToString();
|
|
}
|
|
else
|
|
{
|
|
bValue = bValue[0..^3];
|
|
}
|
|
|
|
if (float.Parse(aValue) > float.Parse(bValue))
|
|
{
|
|
return -1;
|
|
}
|
|
else if (float.Parse(bValue) > float.Parse(aValue))
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
} |