CreamInstaller/CreamInstaller/Components/AppIdComparer.cs
pointfeev 1815f1087d v3.2.2.0
- Large code refactoring and optimizations
- The more essential SteamCMD directories (config and userdata) will no longer be cleaned up by the program, hopefully to speed up the first call
- Games can now also use SteamCMD as a fallback similar to DLC (previously both steam store AND steamCMD output was required for games, now it's either OR)
2022-03-08 18:58:52 -05:00

19 lines
612 B
C#

using System.Collections.Generic;
namespace CreamInstaller.Components;
internal class AppIdComparer : IComparer<string>
{
private static AppIdComparer comparer;
public static AppIdComparer Comparer => comparer ??= new AppIdComparer();
public int Compare(string a, string b) =>
a == "ParadoxLauncher" ? -1
: b == "ParadoxLauncher" ? 1
: !int.TryParse(a, out _) && !int.TryParse(b, out _) ? string.Compare(a, b, System.StringComparison.Ordinal)
: !int.TryParse(a, out int A) ? 1
: !int.TryParse(b, out int B) ? -1
: A > B ? 1
: A < B ? -1
: 0;
}