How to Sort An Array In Console Application?

By Goniey N (Mr. G)

It Will Sort An Given Array In Ascending Using Console Application...

Sub Main()
        
Dim a(10), i, j, temp, n, p As Integer
      
Console.WriteLine("Enter the Number for Sorting:=>")
        n =
Console.ReadLine()

        For i = 0 To n
            a(i) =
Console.ReadLine()
        
Next i

        For i = 0 To n - 1
            
For j = i + 1 To n
                 
If (a(i) > a(j)) Then
                    temp = a(i)
                    a(i) = a(j)
                    a(j) = temp
                 
End If
            
Next j
        Next i

        For p = 0 To n
          
Console.WriteLine(a(p))
        
Next p
      
Console.ReadLine()
End Sub

How to Sort An Array In Console Application?  (827 Views)