I am trying to modify this code that already exists.The code was developed around 2008 and I am trying to fix the sort issue. I am also thinking of changing the code but wanted to fix the issue first.
ArrayList lineEmpNrs = new ArrayList();
taMibMsftEmpDetails employeeDetails; //taMibMsftEmpDetails is a custom class file
while (!HeaderFile.EndOfStream) //headerfile is employee information text file.
{
headerRow = HeaderFile.ReadLine();
headerFields = headerRow.Split(',');
employeeDetails = BuildLine(headerFields[1],headerFields[2],headerFields[3]);
lineEmpNrs.Add(employeeDetails);
}
private taMibMsftEmpDetails BuildLine(string EmpId, string EmpName, String ExpnsDate)
{
taMibMsftEmpDetails empSlNr = new taMibMsftEmpDetails();
empSlNr.EmployeeId = EmpId;
empSlNr.EmployeeName = EmpName;
empSlNr.ExpenseDate = ExpnsDate;
return empSlNr;
}
The Headerfile contains employee expense details. The empID is the key here and the headerFile can contain 'n' number of lines with same EmpID appearing in random order in the file.
I use lineEmpNrs to build some other information based on EmpID. So I want to have lineEmpNrs sorted based on EmpID. I tried the regular sort method but it didn't work.
Please suggest.
Generic List<T>instead..?