diff --git a/EduNetworkBuilder/PersonClass.cs b/EduNetworkBuilder/PersonClass.cs index c2108f4..8b45c7a 100644 --- a/EduNetworkBuilder/PersonClass.cs +++ b/EduNetworkBuilder/PersonClass.cs @@ -512,7 +512,8 @@ namespace EduNetworkBuilder public TreeNode WorkTree(TreeNode theTop=null, bool ForTeacher = false) { //Sort by due date, and within the due dates, sort by save date - Projects.Sort((q, p) => p.DueDate == q.DueDate ? p.SaveDate.CompareTo(q.SaveDate) : p.DueDate.CompareTo(q.DueDate)); + //Projects.Sort((q, p) => p.DueDate == q.DueDate ? p.SaveDate.CompareTo(q.SaveDate) : p.DueDate.CompareTo(q.DueDate)); + Projects.Sort((q, p) => p.Compare(q)); List DrawFrom = new List(); List MasterList = new List(); diff --git a/EduNetworkBuilder/PersonProfileForm.cs b/EduNetworkBuilder/PersonProfileForm.cs index baeda22..d17a90f 100644 --- a/EduNetworkBuilder/PersonProfileForm.cs +++ b/EduNetworkBuilder/PersonProfileForm.cs @@ -292,6 +292,7 @@ namespace EduNetworkBuilder Node.Tag = "Class"; //Do not translate this TreeNode Top = Node; tvClasswork.Nodes.Add(Node); + CurrentUser.Projects.Sort((q, p) => p.Compare(q)); foreach (SchoolworkClass SWC in CurrentUser.Projects) { Node = new TreeNode(SWC.Name); diff --git a/EduNetworkBuilder/SchoolworkClass.cs b/EduNetworkBuilder/SchoolworkClass.cs index fa2687e..3fb660d 100644 --- a/EduNetworkBuilder/SchoolworkClass.cs +++ b/EduNetworkBuilder/SchoolworkClass.cs @@ -90,6 +90,22 @@ namespace EduNetworkBuilder dest.IsGraded = source.IsGraded; } + /// + /// Basically for sorting. First by class name, then due date, and then save date + /// + /// + /// + public int Compare(SchoolworkClass WhatTo) + { + int diff = Class.CompareTo(WhatTo.Class); + if (diff != 0) return diff; + + diff = DueDate.CompareTo(WhatTo.DueDate); + if (diff != 0) return diff; + + return SaveDate.CompareTo(WhatTo.SaveDate); + } + #region Load and Save //Load and save functions public void Load(string filename)