yes i became a cs major isnt that funny try a button green flag to reset please only click one button at a time
The sorting algorithms got progressively harder to simulate and I don't think I will ever do this again... The only variables Scratch has are "global" and "local" variables that are either shared among Sprites or contained within an instance of a Sprite (if you clone a Sprite with a "local variable," the variable will remain independent from other clones). This made the recursive algorithms like merge and quick sort extremely excruciating to implement. Merge Sort was easier to implement than Quick Sort because each recursive call doesn't require you to store "local variables" in each "method" call. To be specific, I used the custom block feature to simulate methods. Custom blocks behave almost like methods, except that you cannot create local variables during runtime within that method. Luckily, it wasn't needed as I could just pass in boundary indexes and calculate from those parameters. (My version of Merge Sort doesn't create separate arrays for the splitting portion.) However, because I needed to store a local "pivot" point for every recursive call on Quick Sort (as the post-partition pivot couldn't be calculated from a formula), I chose to simulate recursion by cloning a Sprite (this quicksort uses Hoare's Partition Algorithm btw). That was my horrible mistake because although you can choose to run scripts upon being cloned, those scripts can run simultaneously if you call clone more than once (a call for the left half and a call for the right half). This breaks the stack structure of recursive calls, which wouldn't have been a problem if I just wanted to sort the array (it actually works fine like this). However, because I wanted to animate it, I ran into some problems as broadcasting an animation call for every two-pointer swap can happen simultaneously with other partitioning instances. This was the bane of my existence. It took me several tries before I successfully simulated a stack by creating an additional list/array. I will not go into detail, but if you want to look into it, the code is all there. Anyhow, this was a lot harder than I thought. I wasted a lot of time doing this. I don't think this will help any of my resumes, but at least it was an interesting endeavor.