-
Book Overview & Buying
-
Table Of Contents
.NET 4.0 Generics Beginner's Guide
By :
If you need some efficient sorting algorithm wrapped in a generic method, C5 has some in store for you. It has three sorting algorithms exposed as static methods of the class Sorting, which are as follows:
IntroSort
HeapSort
InsertionSort
All these sorting mechanisms operate on an array of T, and all of these algorithms operate in-place. This means once you operate them on an array, you will be left with the sorted array and will lose the original unsorted array. We can use them to sort different collections as follows:
IntroSort is an unstable version of QuickSort that can be used in situations where QuickSort fails to offer high performance, such as in the case of almost sorted collections. HeapSort is also as efficient as IntroSort. However, in practice, it is a little slower than IntroSort:
int[] a = new int[]{1, 42, 32, 22, -1, 0};
Console.WriteLine("Before Sorting");
a.ToList().ForEach(c => Console.Write(c + " "));
C5...
Change the font size
Change margin width
Change background colour