19 lines
549 B
C#
19 lines
549 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Chrosey.Extensions.Helper
|
|
{
|
|
public class SemiNumericComparer : IComparer<string>
|
|
{
|
|
public int Compare(string x, string y)
|
|
{
|
|
if (x.IsDate() && y.IsDate())
|
|
return DateTime.Parse(x).CompareTo(DateTime.Parse(y));
|
|
if (x.IsNumeric() && y.IsNumeric())
|
|
return x.CompareTo(y);
|
|
if (x.IsNumeric())
|
|
return 1;
|
|
return y.IsNumeric() ? -1 : string.Compare(x, y, true);
|
|
}
|
|
}
|
|
} |