Lecture overview -- Keyboard shortcut: 'u'  Previous page: Sample use of the Find operations in <b><kbd>List<T></kbd></b> -- Keyboard shortcut: 'p'  Next page: Sample use of BinarySearch in <b><kbd>List<T></kbd></b> -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 15 : 36
Object-oriented Programming in C#
Collection Classes
Sample use of Sort in List<T>

An illustration of three different overloads of Sort operations

/user/normark/oop-csharp-1/sources/c-sharp/collections/list/1/prog.csFour different activations of the List.Sort method. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/collections/list/1/outputOutput of the sorting program.


  • Lessons learned

    • Some types have a default comparer which is used by List.Sort()

    • The default comparer of T can extracted by Comparer<T>.Default

    • An anonymous delegate comparer is attractive if the default comparer of the type does not exist, of if it is inappropriate.

Go to exerciseShuffle List
Go to exerciseCourse and Project classes