Yeah simple bubble sort
Define an array [] of integers
Define a counter , lets say its called 'i'
Use a for loop with another loop nested in it
e.g For (i = 0; i<Size of array; i++)
what this means is start the counter at zero. Add 1 to it each time we go round the loop until it = the size of the array (meaning we have read every element in it)
Within that check to see if the first number which is array[i] is > or < than the one after it which would logically be array[i+1]. If so, swap them so they are in order (use a temporary variable)
Keep doing this.
This is where the second loop comes in. We want to keep repeating this whole process for the whole dataset until we go through it and there is not a single swap (indicating its sorted)
Use a boolean variable for that. e.g nest the for loop in a do while loop which runs while !=sorted.
Dont know how to code this in vb, I have Java code if that helps?
Last edited by jbennet; Nov 26th, 2008 at 9:55 am.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
Offline 16,485 posts
since Apr 2005