Seems you're very beginer...
As i mentioned in the comment to the question, there's no chance to compare strings the same way as integers. You have to use proper
data type[
^].
One of the way to sort array is to use
Linq[
^]. See:
Dim iGrades() As Integer = {10, 33, 40, 50, 22, 33}
Dim result = iGrades _
.OrderByDescending(Function(x) x) _
.GroupBy(Function(x) x) _
.Select(Function(grp, iterator) New With _
{ _
.Index = iterator + 1, _
.Values = String.Join(", ", grp.Select(Function(x) x)) _
}) _
.ToList()
For Each g In result
Console.WriteLine("{0} - {1}", g.Index, g.Values)
Next
Result:
1 - 50
2 - 40
3 - 33, 33
4 - 22
5 - 10
View words about above Linq query:
.OrderByDescending()
- sorts data in descending order
GroupBy()
- creates groups of the same values
Select()
- creates new data set, where
iterator
is used to get the index for each group.
Note, that when you're trying to sort strins, a result may differ. Check this:
Dim sGrades() As String = {"10", "33", "40", "50", "22", "33", "11", "1", "111"}
Dim result = sGrades _
.OrderByDescending(Function(x) x) _
.GroupBy(Function(x) x) _
.Select(Function(grp, iterator) New With _
{ _
.Index = iterator + 1, _
.Values = String.Join(", ", grp.Select(Function(x) x)) _
}) _
.ToList()
For Each g In result
Console.WriteLine("{0} - {1}", g.Index, g.Values)
Next
Result:
1 - 50
2 - 40
3 - 33, 33
4 - 22
5 - 111
6 - 11
7 - 10
8 - 1
Take a look at bolded and underlined "numbers"!
But...
You have to starts with basics:
Arrays in Visual Basic[
^]
How to: Sort An Array in Visual Basic[
^]
Sorting Algorithms In VB[
^]