I have written a whole bunch of objects that are all parts of collections and on which I will need to do lots of sort and search. On most of these object I have implemented and overridden the Equals
method, IEquatable
and operator!
and operator==
.
Now I come to wanting to use List<T>.Sort
on an object having implemented all above and it turns out I need to implement IComparable
to do custom sorting.
Why does Sort use IComparable
and what is then the point of having IEquatable
in all my objects?
Also what does Object.Equal
overriding have to do with all this?