【发布时间】:2015-01-22 09:55:40
【问题描述】:
我有一个 List 包含多个 Lists 本身包含类型对象:
List<List<Activity>> SortActivities
Activity 类型的对象如下所示:
public class Activity
{
public DateTime Date { get; set; }
public string ProjectnumberUnformatted { get; set; }
public int Year
{
get
{
return Date.Year;
}
}
public int Month
{
get
{
return Date.Month;
}
}
public string MonthYear
{
get
{
return Month + " / " + Year;
}
}
public string Customer
{
get
{
return ProjectnumberUnformatted.Split('/')[0];
}
}
public string ProjectnumerFormatted
{
get
{
return ProjectnumberUnformatted.Split('/')[2];
}
}
public string MonthString
{
get
{
switch (Month)
{
case 1:
return "Januar";
case 2:
return "Februar";
case 3:
return "März";
case 4:
return "April";
case 5:
return "Mai";
case 6:
return "Juni";
case 7:
return "Juli";
case 8:
return "August";
case 9:
return "September";
case 10:
return "Oktober";
case 11:
return "November";
case 12:
return "Dezember";
default:
return "Invalid";
}
}
}
public string Start { get; set; }
public string Pause { get; set; }
public string End { get; set; }
public string Description { get; set; }
public string Comment { get; set; }
}
在程序启动时,我有一个对象List<Activity>,其中包含未排序的活动。但是,每个活动都应按其项目编号排序。所以我需要实现一个方法,将List<Activity> 对象中的每个活动排序到它自己的List<Activity> 中,并将项目编号作为排序参数。然后将生成的列表放入List<List<Activity>>。
如果可能的话,我只需要一个基本流程图,并使用一个简单的算法来完成这项工作,因为我真的不知道如何开始。
【问题讨论】:
-
我认为分阶段进行:移至 Dictionary(Dictionary
>) 而不是重新考虑您的问题,因为它太复杂,无法提供简单的可重复使用的答案,稍后尝试 LINQ 来安排它跨度>
标签: c# sorting multi-level