David Chen

David Chen

  • NA
  • 50
  • 45.7k

Sort a field with in a 2D Array

Mar 12 2013 3:50 PM

First I have 2 classes

class Student {     int StudentID     string Name     Fee fee } class Fees {     int FeeID     string FeeName     DateTime FeeDueDate }

let say there are 10 students objects Student[] stud = new Student[10]

and if stud[0] has 4 fees ( Fee[4] ) and they are

FeeID=1, FeeName="Books", FeeDueDate="2014/06/25" FeeID=2, FeeName="Tuition", FeeDueDate="2013/03/21" FeeID=3, FeeName="Sports Equipment", FeeDueDate="2013/03/18" FeeID=4, FeeName="School Dorm", FeeDueDate="2013/07/26"

while stud[1] has 2 fees ( Fee[2] ) and they are

FeeID=2, FeeName="Books", FeeDueDate="2014/06/20" FeeID=4, FeeName="School Dorm", FeeDueDate="2013/03/26"

and stud[2] has ......

I need the sort the second collection which is the Fee by FeeDueDate asscending while Keep the same order of student

so after sorting would be

stud[0] =>  FeeID=3, FeeName="Sports Equipment", FeeDueDate="2013/03/18" FeeID=2, FeeName="Tuition", FeeDueDate="2013/03/21" FeeID=4, FeeName="School Dorm", FeeDueDate="2013/07/26" FeeID=1, FeeName="Books", FeeDueDate="2014/06/25"  stud[1] =>  FeeID=4, FeeName="School Dorm", FeeDueDate="2013/03/26" FeeID=2, FeeName="Books", FeeDueDate="2014/06/20"

How can this be done? Thanks

Also this image shows my collections of objects http://oi50.tinypic.com/wuq9o3.jpg


Answers (6)