You also know how an IComparer interface allows any type to compare two objects of the same or different types. Both of these types rely on the object being compared as implementing the IComparable interface. Now, let's see how we apply all this knowledge to a collection so items are sorted the way we want them. Certain collections, such as SortedList and Hashtable, offer constructors that accept an object implementing the IComparer interface. Once constructed, these collection types use the IComparer object when any new items are added to the collection.
Some collections use a different paradigm.
For example, the Array and ArrayList collections, just maintain a set of objects. At any given point, you may sort the items that are currently in the collection by calling either type's Sort method. The Sort method has a parameter that accepts an object implementing the IComparer interface. When Sort is called, it sorts all the items in the collection using the specified IComparer object. This paradigm is more flexible than the constructor paradigm because you can sort the collection items using one IComparer object and then resort the items using a different IComparer object.