Tuesday, October 17, 2006

Sorting an Array/ArrayList


So you have an array with alpha elements that you want sorted?

Use the ArrayList.Sort or Array.Sort its that simple

As long as the array contains elements that are of datatypes that implement the IComparable interface then it can be sorted. The basic datatypes all support this interface!

So what happens if some of the elements don't support this interface? You must pass the Sort method to an object that implements the System.Collections.IComparer interface.

No comments: