Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27193

VS 2010 [RESOLVED] Arraylist - Sorting Textual Entries From Highest To Lowest

$
0
0
I was wondering how to sort an arraylist properly from highest to lowest value when textual content is added rather than numerical.

Code:

Dim a1 As New ArrayList

a1.Add("20  Items")
a1.Add("112 Items")
a1.Add("4 Items")
a1.Add("11 Items")

a1.Sort()
a1.Reverse()

For Each i In a1
MsgBox(i)
Next

' Results:  4 Items / 20 Items  / 112 Items / 11 Items

When I add integer values instead:
a1.Add(20)
a1.Add(112)
a1.Add(4)
a1.Add(11)

things are sorted well: 112 / 20 / 12 / 4.

Is there a way to get this second type of sorting with textual content too?

Viewing all articles
Browse latest Browse all 27193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>