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
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Matthew CochranRank #252 · 10K reputationPosted Jun 14, 2007, 1:20 PM EDT
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; }
}
}