ArrayList sorting Sort () method (convert), arraylistsort
// Use the Sort method to Sort the elements in the set. Sort has three methods for overloading. The declaration code is as follows. Public void Sort (); // Sort public void Sort (IComparer comparer) by comparing set elements; // Sort public void Sort (int index, int count, IComparer comparer) // Sort the specified range using a custom comparator. Note: to Sort all elements in the set using the Sort method, the IComparable interface must be implemented. Otherwise, will throw an exception. The first method is used to sort the instance using System; using System. collections; class Program {static void Main (string [] args) {ArrayList al = new ArrayList (); al. addRange (new string [8] {"Array1", "Array2", "Array3", "Array5", "Array4", "Array8", "Array7 ", "Array6"}); al. sort (); foreach (string s in al) {Console. writeLine (s);} Console. readLine ();}}