Sorting and reversing an array in VB.NET

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
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now