while sorting an Integer array, numbers are sorting wrongly.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MK0023490
    New Member
    • Feb 2014
    • 1

    #1

    while sorting an Integer array, numbers are sorting wrongly.

    Hi,

    suppose an array consists of values

    dim arrnum() as integer=nothing

    arrnum consists of values (3,8,6,15,2,10)

    while using Array.sort(arrn um)

    valuse are sorted like way. (10,15,2,3,6,5)

    actually i need values in a sorted way.

    can you help me out.

    thanks,
  • dimis164
    New Member
    • Feb 2014
    • 2

    #2
    Check out this one:
    Code:
      Dim myarray(3) As Integer
            myarray(0) = 15
            myarray(1) = 2
            myarray(2) = 11
            myarray(3) = 5
            Array.Sort(myarray)
    it works perfect on my project

    Comment

    • dimis164
      New Member
      • Feb 2014
      • 2

      #3
      also my opinion is to use list instead of array.. it has a lot more option to help you. here is the same example with a list:
      Code:
        Dim myList As New List(Of Integer)
              myList.Add(15)
              myList.Add(2)
              myList.Add(11)
              myList.Add(5)
              myList.Sort()

      Comment

      Working...