I have an array of strings such as "blue", "green", "red" and I wish to sort them so the longest string comes first and the shortest last.
Currently I am creating another array with the lengths of each string in the array in the same index positions and using this array as the key array to sort by as can be seen below, but I think this could be optimised into one line perhaps?
Dim colours() As string = {"blue", "green", "red"}
Dim colourslength() As Integer
For i As Integer = 0 To colours.Length - 1
colourslength(i) = colours(i).Length
Next
Array.Sort(colourslength, colours)
Array.Reverse(colours)
Edit: just realised I defined colours as a list in the example code, it's an array in my actual code.