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
VulpesPosted Mar 12, 2013, 6:06 PM
VulpesPosted Mar 12, 2013, 7:04 PM
David ChenPosted Mar 12, 2013, 6:28 PM
if Fee has another properties called FeeAmount
now I need to sort the students collection BY the max fee amounted added together
how is it this done
I have been working on this forever, my brains hurts with 2 dimensional stuff ><
if stud[0] has 2 fees ( Fee[2] ) and they are
if stud[1] has 1 fees ( Fee[1] ) and they are
if stud[2] has 3 fees ( Fee[3] ) and they are
I need to sort the Student Collections by TotalAmount(Fee Collection)
there for after sorted it should become
David ChenPosted Mar 12, 2013, 6:25 PM
David ChenPosted Mar 12, 2013, 5:40 PM
I just updated the question as I was using an example
but when I apply
objStudentWithFeeData = objStudentWithFeeData.OrderBy(stu => stu.Fees.DueDate).ToList();
there is an error here: stu => stu.Fees.DueDate
it cant find DueDate in stu.Fees.
you can see my collections here http://oi50.tinypic.com/wuq9o3.jpg
VulpesPosted Mar 12, 2013, 5:10 PM
Here's an example:
The output should be: