如何按元素的第一列对以下列表进行排序?元素是 type string[]
。
List<string[]> list = new List<string[]>();
这可能会有所帮助
list.OrderBy(input=>input[columnIndex])
使用Enumerable.OrderBy
列索引的方法;
按升序对序列的元素进行排序。
string[] i = new string[] { "one", "two", "three" };
string[] j = new string[] { "four", "five", "six" };
List<string[]> list = new List<string[]>() {i, j};
var newlist = list.OrderBy(n => n[1]);
这将返回一个新的排序列表。