In a nutshell :
List/Array Sort() :
- Unstable sort.
- Done in-place.
- Use Introsort/Quicksort.
- Custom comparison is done by providing a comparer. If comparison is expensive, it might be slower than OrderBy() (which allow to use keys, see below).
OrderBy/ThenBy() :
- Stable sort.
- Not in-place.
- Use Quicksort. Quicksort is not a stable sort. Here is the trick : when sorting, if two elements have equal key, it compares their initial order (which has been stored before sorting).
- Allows to use keys (using lambdas) to sort elements on their values (eg :
x => x.Id
). All keys are extracted first before sorting. This might result in better performance than using Sort() and a custom comparer.
Sources:
MDSN, reference source and dotnet/coreclr repository (GitHub).
Some of the statements listed above are based on current .NET framework implementation (4.7.2). It might change in the future.