June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to sort an Array or ArrayList, but the items it contains do not implement IComparable.
Create a custom IComparer that can sort the type of object contained in the Array or ArrayList. Pass an instance of this IComparer object to the Sort method of the Array or ArrayList object.
Some objects define a native sort order by implementing the IComparable interface. Others do not, either because there’s no obvious criteria to use for sorting, or because there are several equally valid sort criteria. In these cases, you can create a custom IComparer, which is an object with a single purpose in life—to sort a specific type of object.
There are two reasons that you might use ...
Read now
Unlock full access