0

我想要做的是通过数组中的信息重新排序数组列表。例如,我的列表可能有 20 个 Long[] 数组,我想按 Highest Totallaps 和 Lowest TotalTime 进行排序 尝试了几件事,尽管想不出任何问题。任何帮助将不胜感激。

public List<long[]> Reorderedlist()
{
    _timeKeeper._timeKeeperControls controls = new _timeKeeper._timeKeeperControls();

    List<long[]> returnList = new List<long[]>();

    List<long[]> listToReOrder = new List<long[]>();

    listToReOrder = controls.teamInfoInClass("1",ContactlessTimer.Properties.Settings.Default.currentRaceID);

    //newlist contains list of long[] arrays
    //each array contains

    //long[0] = id1 (eg 33) 
    //long[1] = id2 (eg 34)
    //long[2] = totalLaps (eg 10)
    //long[3] = total time (eg 340000 in miliseconds)

    foreach (long[] Arr in listToReOrder)
    {
        foreach (long info in Arr)
        {
            //order
        }
    }

    return returnList;
}
4

1 回答 1

2

使用 LINQ 方法:OrderByDescendingThenBy

List<long[]> returnList = listToReOrder.OrderByDescending(x => x[2])
                                       .ThenBy(x => x[3])
                                       .ToList();
于 2013-04-21T14:46:06.133 回答