Sorting uses QuickSort and does not guarantee the original sequence in case of equality of comparisons.
If you still want to use List.Sort, you can add a second comparison with the original index, for example:
int c = this.sortIndex.CompareTo(other.sortIndex); if (c == 0) c = this.originalIndex.CompareTo(other.originalIndex); return c;
otherwise, you can sort with other "stable" algorithms (for example, LINQ OrderBy).
source share