Re: HELP!!! with Bubblesort
Welcome to the forums :wave:
You would probobally get better help on the .NET section of the forum or wait for mod to move the thread for you ;)
Re: HELP!!! with Bubblesort
Re: HELP!!! with Bubblesort
The only reason that I can think of that you would want to implement your own bubble sort rather than using the inbuilt Array.Sort method is this is homework and that's a requirement. In that case it is inappropriate for us to simply provide the code for you.
As with any algorithm, the way to implement a bubble sort is to first write out the steps in words. You then write pseudo-code that corresponds to the words and, finally, you write VB code that corresponds to the pseudo-code. To go straight from the idea to the VB code is the lazy way because it seeks to remove the intermediate steps, but it actually makes things much harder. We all tried to do it when we were learning but, believe me, if you follow the proper steps the solution will come much more easily and you will learn more.
If you make an attempt at an implementation and run into issues then you can post again with more specific questions.
Also, please wrap your code in VBCODE tags to make it more readable.
Re: HELP!!! with Bubblesort
Just in case this isn't actually homework, and you have reason to write your own sort instead of using the Array.Sort, you might look up Shell sort. It's really bizarre, but it is also REALLY simple to code. Bubble sort is just about the worst possible sort algorithm out there. I much prefer Shell sort for custom sort routines, because I don't have to worry about the (rare) problems that QSort has. QSort is probably the algorithm used in Array.Sort, and is the fastest sort algorithm in most cases, but can be horribly slow in certain specific cases. I've also never seen a particularly simple code example of QSort, though there has to be one out there. The reason I have never seen one might simply be that it has been built into libraries for languages like C/C++, so you don't get the algorithm, you get a dll and a function prototype.