I have
List<string> strs; double[] values;
where the array of values ββcontains the value of each line in the strs list
Say strs={"abc","def","ghi"} and values={3,1,2} this means that "abc" has a value of 3, etc.
I want to sort strs and values ββsorted by values ββso that it becomes
strs={"def","ghi","abc"} values={3,2,1}
I use
string[] strsArr = strs.ToArray(); Array.Sort(values, strsArr);//1. sort it ascendingly strs = strsArr.ToList(); Array.Reverse(strs);//2. reverse it
Is there a way to sort it in a descending order directly without two phases?
source share