First I have 2 classes
C#
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
C#
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
C#
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
C#
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
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2013, 2:06 PM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2013, 1:10 PM EDT
Here's an example:
The output should be:
David Chen60 reputationPosted Mar 12, 2013, 1:40 PM EDT
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
David Chen60 reputationPosted Mar 12, 2013, 2:25 PM EDT
David Chen60 reputationPosted Mar 12, 2013, 2:28 PM EDT
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
FeeID=1, FeeAmount=54.23 FeeID=2, FeeAmount=234.98if stud[1] has 1 fees ( Fee[1] ) and they are
FeeID=1, FeeAmount=9.99if stud[2] has 3 fees ( Fee[3] ) and they are
FeeID=1, FeeAmount=123.45 FeeID=2, FeeAmount=67.89 FeeID=3, FeeAmount=987.65I need to sort the Student Collections by TotalAmount(Fee Collection)
TotalAmount of Fee stud[0] = 54.23+234.98=289.21 stud[1] = =9,99 stud[2] = 123.45+67.89+987.65=1178.99there for after sorted it should become
stud[0] = 123.45+67.89+987.65=1178.99 stud[1] = 54.23+234.98=289.21 stud[2] = =9,99VulpesRank #55 · 29.2K reputationPosted Mar 12, 2013, 3:04 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts