Blog

Sorting and reversing an array in VB.NET

Posted by Darwin Chaudhary Blogs | Visual Basic .NET Aug 29, 2011
Here, we will see how to use sorting and reversing an array.
Introduction

An  array is a group of contiguous or related data items that the share a conman name.

For example

This program defines the sorting and reversing an array.

Module Module1

    Sub Main()

        Dim x As Integer() = {30, 10, 80, 90, 20}

        Console.WriteLine("array before sorting")

        For Each i As Integer In x

            Console.Write("" & i)

        Next

        Console.WriteLine()

        Array.Sort(x)

        Array.Reverse(x)

        Console.WriteLine("Array after sorting and Reversing")

        For Each i As Integer In x

            Console.WriteLine(" " & i)

        Next

        Console.WriteLine()

    End Sub

End Module

Output of program:


console1.gif
comments
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Nevron Chart
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Nevron Diagram