- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
public static IEnumerable<T> QuickSort<T>(
this IEnumerable<T> source) where T : IComparable<T>
{
if (!source.Any()) return source;
var first = source.First();
return source
.AsParallel()
.GroupBy(i => i.CompareTo(first))
.OrderBy(g => g.Key)
.SelectMany(g => g.Key == 0 ? g : QuickSort(g));
}