Posted by: Sourav | September 19, 2016

Sort and reverse sort a list in VB,VB Teacher Sourav,Kolkata 09748184075


Option Strict On
Option Explicit On
Imports System

Module Module1

Sub Main()
Dim numbers As List(Of Integer) = New List(Of Integer) From {9, 5, 7, 6, 2, 3}

Console.WriteLine(“List before soring”)
For Each i As Integer In numbers
Console.WriteLine(i)

Next

numbers.Sort()

Console.WriteLine(“List after soring”)
For Each i As Integer In numbers
Console.WriteLine(i)

Next

numbers.Reverse()

Console.WriteLine(“List after soring in opposite direction”)
For Each i As Integer In numbers
Console.WriteLine(i)

Next

Dim names As List(Of String) = New List(Of String) From {“Sourav”, “Amiya”, “Bidhan”, “Koushik”, “Pradhan”}
Console.WriteLine(“List before soring”)
For Each n As String In names
Console.WriteLine(n)

Next

names.Sort()

Console.WriteLine(“List after soring”)
For Each n As String In names
Console.WriteLine(n)

Next

numbers.Reverse()

Console.WriteLine(“List after soring in opposite direction”)
For Each n As String In names
Console.WriteLine(n)

Next
Console.ReadLine()

End Sub

End Module

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: