View Single Post
 
Old March 12th, 2008, 02:07 AM
samjudson's Avatar
samjudson samjudson is offline
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Code:
List<csvLine> lines = new List<csvLine>();
The you can just do:

Code:
foreach(csvLine line in lines)
{
   Console.WriteLine(line.clNumb);
}
The Compare function returns 0 if the two items are the same, so simply check that value and if they are then move to the second item you want ot sort by:

Code:
public int Compare(object x, object y)
{
  csvLine l1 = x as csvLine;
  csvLine l2 = y as csvLine;
  if (l1 != null && l2 != null)
  {
    int c = Comparer.Default.Compare(l1.clNumb, l2.clNumb);
    if( c != 0 )
      return c;
    return Comparer.Default.Compare(l1.clChan, l2.clChan);
  }
  else
  {
    throw new ArgumentException("One or both objects to compare are not csvLine objects.");
  }
}
/- Sam Judson : Wrox Technical Editor -/