I'm implementing a custom comparer in order to apply a custom sort order for items in various views.
Some of the time I'm finding that I want to maintain the existing order of items, in this case what should I return from my Compare
method implementation? Is it enough to simply return 0, or do I actively need to identify which item came first?
x
equalsy
, which in theory means that the sorter can put those two items in whatever order it chooses – CarcanetEnumerable.OrderBy
does a stable sort,List<T>.Sort
is not stable, so it could re-order equal elements. – Amusing