List<int> _lstNeedToOrder = new List<int>();
_lstNeedToOrder.AddRange(new int[] { 1, 5, 6, 8 });
//I need to sort this based on the below list.
List<int> _lstOrdered = new List<int>();//to order by this list
_lstOrdered.AddRange(new int[] { 13, 5, 11, 1, 4, 9, 2, 7, 12, 10, 3, 8, 6 });
order will be -->_lstNeedToOrder = 5,1,8,6
我该怎么做呢?
IndexOf
来查找每个条目的所需索引。这在_lstOrdered
的大小上是一个O(n)的操作,是不必要的。 - Jon SkeetIndexOf
? - King King