Maha

Maha

  • NA
  • 0
  • 326.1k

Array.Sort() and Sort()

Sep 15 2013 7:27 AM
When we sort an Array we use Array.Sort() and when we sort ArrayList we use Sort(). Please explain the reason. Example is given below.

eg:-

Employee[] empArray = new Employee[] { new Employee(333, 12.50), new Employee(111, 14.75), new Employee(222, 22.35) };

Array.Sort(empArray);

eg:-

ArrayList people = new ArrayList(); //this requires using System.Collections;

people.Add(new Person("John", "Doe", 84));
people.Add(new Person("Abby", "Normal", 25));
people.Add(new Person("Jane", "Doe", 76));

people.Sort();


Answers (2)