mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-12 17:03:10 +00:00
30 lines
823 B
C#
30 lines
823 B
C#
using System.Collections.Generic;
|
|
|
|
namespace CryptoExchange.Net.Objects
|
|
{
|
|
/// <summary>
|
|
/// Order string comparer, sorts by alphabetical order
|
|
/// </summary>
|
|
public class OrderedStringComparer : IComparer<string>
|
|
{
|
|
/// <summary>
|
|
/// Compare function
|
|
/// </summary>
|
|
/// <param name="x"></param>
|
|
/// <param name="y"></param>
|
|
/// <returns></returns>
|
|
public int Compare(string x, string y)
|
|
{
|
|
// Shortcuts: If both are null, they are the same.
|
|
if (x == null && y == null) return 0;
|
|
|
|
// If one is null and the other isn't, then the
|
|
// one that is null is "lesser".
|
|
if (x == null) return -1;
|
|
if (y == null) return 1;
|
|
|
|
return x.CompareTo(y);
|
|
}
|
|
}
|
|
}
|