Press the "Shuffle" button to create a bunch of bars, in no particular order. Then, press a button to sort them. Press the "Stop" button to stop the sorting algorithm. Sorting Algorithm Explanations (Unfinished): 1. Bubble Sort Bubble Sort takes the first two bars and compares them, if the second bar should be before the first one, then it will switch the two. Then it will take the second and third bars and do the same, then it will take the third and fourth bars, and so on. It will repeat this process until all the bars have been sorted. 2. Insertion Sort Insertion Sort takes the first two bars and compares them, if the second bar should go before the first bar, then it will switch the two. Then it will take the third bar and compare it with the first and second bars, if it should go behind one of them, then it will switch the two. Then it will take the fourth bar and compare it with the first, second, and third bars, and so on. It repeats the process until all bars are sorted. 3. Selection Sort Selection Sort finds the smallest number of the array, and swaps it with the first number in the array if the two are not the same. Then, it finds the second smallest number of the array, and swaps it with the second number in the array, then it will finds the third smallest number, and so on. It will repeat this process until the array is sorted. 4. Shell Sort Shell sort takes the first bar and compares it to a bar that is a fixed number to its right. If the two aren't in order, then it swaps them. Then, it takes the second bar and compares it to a bar the same fixed number to its right. If the two are out of order, then it swaps them. After it swaps the two, it will compare the bar to the bar the same fixed number to its left, and compare those two and swap if needed. It repeats this process until it reaches the last bar, where it halves the fixed number and starts from the beginning. It repeats this process until all the bars are sorted. 5. Cocktail Sort Cocktail Sort takes the first two bars and compares them, if the second bar should be before the first one, then it will switch the two. Then it will take the second and third bars and do the same, then it will take the third and fourth bars, and so on. Once it reaches the last bar, it will reverse this process. So it will compared the last and second-to-last, second-to-last and third-to-last, and so on. It repeats this process until all the bars are sorted. 6. Gnome Sort Gnome Sort takes the first two bars and compares them. If they're not in order, then it will swap them. Then it will take the next two bars and compares them. If they're not in order, then it will swap them and start going backwards, meaning it will compare the first two bars next. But if they are in order, then it will keep going forwards. Then it will do the same for the next (or previous) two numbers, and so on. 7. Quick Sort Quick Sort takes the bar in the middle, and calls it "the pivot", then it will compare every other bar to the pivot's bar. Then, it puts everything that should be before the pivot bar to the left of it, and everything that shouldn't to the right of it. This creates two new "groups" of bars, which it then creates new pivot bars in those. It repeats this process until all bars are sorted. 8. Merge Sort Merge Sort will break up the current set of bars and break it up into many smaller subsets of bars. Then it will sort all of those extremely small subsets, and merge two of them to make a larger subset. It will do this for all of the extremely small subsets. Then, it will merge two of the larger subsets to make an even larger subset. It will keep merging until all the bars are sorted. 10. Radix Sort (Least Significant Digit) Every bar corresponds to a number in an array. Radix Sort by Least Significant Digit takes every bar's number and finds their ones digit. Then, it will distributive them by their ones digit. Then, it will do the same thing with each bar's number's tens digit. It will repeat this until it reaches the final digit. 11. Radix Sort (Most Significant Digit) Every bar corresponds to a number in an array. Radix Sort by Most Significant Digit takes every bar's number and finds their first digit. Then, it will use another sorting algorithm to sort these numbers by their first digit. Then, it will do the same thing with each bar's number's second digit. It repeats this until it reaches the final digit. 12. Odd-Even Sort Odd-Even sort takes the first odd number and compares it with the first even number, and swaps if they're out of order. Then it takes the second odd number and compares it with the second even number 13. Bogo Sort Bogo Sort just randomizes the whole thing until it's sorted.
If you liked this project, check out some of my other projects! All coding by me. Check out my other project where you can see the sorting algorithms compared to one another! Sorting Algorithms Comparison: https://scratch.mit.edu/projects/706774424/