So as the title already suggests I simply want to know if it is possible to sort elements that are in a string array via the numbers that are also contained within those strings.
In my program I have been able to read the contents of a file which are laid out like this:
Adele got 2,Jack got 8
I have then been able to split this file via the comma into a string array called names:
Dim fileReader As System.IO.StreamReader
Dim line As String
fileReader = My.Computer.FileSystem.OpenTextFileReader(ClassA)
line = fileReader.ReadLine
names = line.Split(",")
For Each element As String In names
Array.Sort(names)
Console.WriteLine(element)
Next
I was also able to sort the file alphabetically giving an output of:
Adele got 2
Jack got 8
However what I want to know is whether it is or isn't possible to sort these strings based on the number so the output would look like:
Jack got 8
Adele got 2
I also considered using regex to extract the numbers, parse them as integer, save them to a variable and then add them to an array and compare the arrays but their has to be a simpler way D:
Any help is much appreciated guys :)
For Eachbit.