ARTICLE

How to perform Sorting an ArrayList in VB.NET

Posted by Manish Tewatia Articles | Visual Basic Language July 28, 2010
In this article I will show a example of sorting of strings in array.
 
Reader Level:

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

2.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.

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Diagram
Become a Sponsor