Use own IComparer with Linq OrderBy

Your comparer looks wrong to me. You’re still just sorting in the default text ordering. Surely you want to be parsing the two numbers and sorting based on that: public int Compare(Object stringA, Object stringB) { string[] valueA = stringA.ToString().Split(“https://stackoverflow.com/”); string[] valueB = stringB.ToString().Split(“https://stackoverflow.com/”); if (valueA.Length != 2 || valueB.Length != 2) { stringA.ToString().CompareTo(stringB.ToString()); } … Read more

Using IComparer for sorting

You need to implement the strongly type interface (MSDN). public class CoordinatesBasedComparer : IComparer<Point> { public int Compare(Point a, Point b) { if ((a.x == b.x) && (a.y == b.y)) return 0; if ((a.x < b.x) || ((a.x == b.x) && (a.y < b.y))) return -1; return 1; } } BTW, I think you use … Read more

difference between IComparable and IComparer [duplicate]

As the name suggests, IComparable<T> reads out I’m comparable. IComparable<T> when defined for T lets you compare the current instance with another instance of same type. IComparer<T> reads out I’m a comparer, I compare. IComparer<T> is used to compare any two instances of T, typically outside the scope of the instances of T. As to … Read more

Pass a lambda expression in place of IComparer or IEqualityComparer or any single-method interface?

I’m not much sure what useful it really is, as I think for most cases in the Base Library expecting an IComparer there’s an overload that expects a Comparison… but just for the record: in .Net 4.5 they’ve added a method to obtain an IComparer from a Comparison: Comparer.Create so you can pass your lambda … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)