I’d like to sort a List<string>, but at the same time sort a float[] array: which are the associated values. (I know this is bad design, it is so historically). So whenever two items are swapped in the List I would like the values at the indexes in the array also swapped. There’s a method for doing this with two arrays: http://msdn.microsoft.com/en-us/library/aa311223%28v=vs.71%29.aspx
However I can’t find anything for a List and an array: is there such a method somewhere?
I’d like to sort a List<string> , but at the same time sort a
Share
You can use
Zip(.NET 4.0 and above) to merge the list and array and perform the sort on the result.Update:
Since you are using .NET 3.5, you can use
Array.Sort, as you have linked to, converting the list to an array first:The way I would normally do this, however, would be with creating a type holding a
stringandfloat, and use that in a generic collection to sort.