使用linq排序,想改进下,求指教
/// <summary>
/// 对数据源进行排序
/// </summary>
/// <param name="pStudentInfoList">需要排序的数据源</param>
/// <param name="pSortExpression">排序字段</param>
/// <param name="pSortDeriction">排序的方向</param>
/// <returns>StudentInfo类型的list</returns>
public static List<StudentInfo> GetListSorted(List<StudentInfo> pStudentInfoList, SortKeys pSortExpression, SortDeriction pSortDeriction)
{
List<StudentInfo> ds = new List<StudentInfo>();
if (pSortDeriction == SortDeriction.DESC)
{
switch (pSortExpression)
{
case SortKeys.StudentId:
ds = pStudentInfoList.OrderByDescending(studentinfo => studentinfo.StudentId).ToList<StudentInfo>();
break;
case SortKeys.StudentName:
ds = pStudentInfoList.OrderByDescending(studentinfo => studentinfo.StudentName).ToList();
break;
case SortKeys.Birthday:
ds = pStudentInfoList.OrderByDescending(studentinfo => studentinfo.Birthday).ToList();
break;
case SortKeys.Sex:
ds = pStudentInfoList.OrderByDescending(studentinfo => studentinfo.Sex).ToList();
break;
}
}