I have a List where element is:
struct element {
double priority;
int value;
}
How can I implement my own comparer which allow me sort List by priority ? I try with SortredList… but it don’t allow douplicated keys 🙁
Big thanks for help!
If you can’t rely on C# 3 extensions or Lambdas then you can have your struct implement the IComparable interface, like so:
There are also a typesafe version of this interface, but the principle is the same
After you have that interface implemented on your struct or class, calling the Sort method on
List<>will “just work”