Nithika

Nithika

  • NA
  • 63
  • 18k

sorting issue

Jan 27 2016 4:01 AM
In my app I have a list of one class,, want to sort the alphanumeric value and I want my result as, N1-1,N1-20,N1-100,N1-10000,N1-8100.How can I get this?                 

List<Employee> employeeList = new List<Employee>()
  {         new Employee { Name = "N1", Salary = "N1-1" } ,                    
                  ...

           };

        SortSalary sortSal = new SortSalary();
        employeeList.Sort(sortSal);

  }

class SortSalary: IComparer<Employee>
{
    #region IComparer<Employee> Members

    public int Compare(Employee x, Employee y)
    {
      
        return string.Compare(x.Salary, y.Salary);
    }

    #endregion
}


Answers (2)