sorting array of objects
Greetings, i have created an object like this Employee[] E = new Employee[8];
every object contains informations about every employee one of them is there payment my question is how can i sort those objects ascending from there payment ?
thanks
Matthew CochranPosted Jun 14, 2007, 5:20 PM
Array.Sort(arr, delegate(Employee one, Employee two)
{
return one.Payment.CompareTo(two.Payment);
});
with the following class:
class Employee
{
public Employee(int payment)
{
m_payment = payment;
}
private int m_payment;
public int Payment
{
get { return m_payment; }
set { m_payment = value; }
}
}