How to perform Sorting an ArrayList in VB.NET

In this article I will show a example of sorting of strings in array.
  • 4149

As you now ArrayList is the data structure which is most flexible. ArrayList contains a simple list of values and very easily we can add , insert , delete , view , sort etc.. to do with ArrayList. It is very flexible becuse we can add without any size information , that is it grow dynamically and also shrink. In this article we see how to performe sorting.
 

EXAMPLE

    Imports System.Collections
    Module module1
        Sub Main()
            Dim StringArray() As String = {"manish", "is", "a", "student"}
            Array.Sort(StringArray)
            Dim a As IEnumerator = StringArray.GetEnumerator()
            While (a.MoveNext())
                Console.WriteLine(a.Current())
            End While
            Console.ReadLine()
        End Sub
    End
Module

OUTPUT

12.gif
 

SUMMARY

As you saw in this example we perform sorting in ArrayList the Array.Sort method was perform this task it sort all the strings in ascending order.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.