By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

while sorting an Integer array, numbers are sorting wrongly.

P: 1
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(arrnum)

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,
Feb 17 '14 #1
Share this Question
Share on Google+
2 Replies


P: 2
Check out this one:
Expand|Select|Wrap|Line Numbers
  1.   Dim myarray(3) As Integer
  2.         myarray(0) = 15
  3.         myarray(1) = 2
  4.         myarray(2) = 11
  5.         myarray(3) = 5
  6.         Array.Sort(myarray)
it works perfect on my project
Feb 17 '14 #2

P: 2
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:
Expand|Select|Wrap|Line Numbers
  1.   Dim myList As New List(Of Integer)
  2.         myList.Add(15)
  3.         myList.Add(2)
  4.         myList.Add(11)
  5.         myList.Add(5)
  6.         myList.Sort()
Feb 17 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.