| | |
arranging 5 numbers from lowest to highest PLS HELP
![]() |
There are many sort algorithms in existance. The simplest but slowest is you have all your values in an array and you know the count of the array.
This one is very inefficient but will do the job. In essence the outer loop will loop forever until no swaps occur in the inner loop. This is know as a bubble sort as the numbers bubble along into their correct positions.
I strongly recommend you read up on sorting. Knuth has a great book on the subject containg pseudo code. His books are well worth having a prominent place in your bookcase.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
swap = true while swap is true swap = false for index = 0 to cnt-1 step 1 if ary[index] > ary[index+1] then tmp = ary[index] ary[index]=ary[index+1] ary[index+1] = ary[index] swap = true endif endfor endwhile
This one is very inefficient but will do the job. In essence the outer loop will loop forever until no swaps occur in the inner loop. This is know as a bubble sort as the numbers bubble along into their correct positions.
I strongly recommend you read up on sorting. Knuth has a great book on the subject containg pseudo code. His books are well worth having a prominent place in your bookcase.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
[45][ 3][21][11][2] 3 45 21 11 2 3 21 45 11 2 3 21 11 45 2 3 21 11 45 2 next outer loop without the little steps 3 11 21 2 45 3 11 2 21 45 3 2 11 21 45 2 3 11 21 45
Last edited by wildgoose; Jul 6th, 2009 at 11:23 am. Reason: adjustment
![]() |
Similar Threads
- Numbers in descending order(HELP)! (C)
- Arranging from lowest to highest? (C)
- Displaying lowest/highest in an Array? (C++)
- Insertion Sort and Number Occurence (C++)
- Arrays (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: how to control hardware using vb
- Next Thread: Can this vb table structure do like that??
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





