This is my implementation of a quicksort algorithm in scratch The best way to use it in your project would prolly be to copy everything from the list you wanna sort to "sortlist" and then back, unless you wanna set all the "sortlist" list blocks to your list lol. The only necessary blocks are "qcksrt" and "sort" In the definition of "qcksrt" there's a loading bar block which you can just remove (you can also delete the "progress (%)" variable), unless you're sorting more than about 3K items or have your own loading bar. If you're sorting like 100K items for example (in Scratch apparently lol), the "sort" block can take a while to run the first couple times, so if you wanna show the user its progress, there's a block in the "two" sprite which you put in the definition of "sort" There's also a "sidesortlist" which will have its contents re-arranged in the same way as "sortlist," so you can also sort the data that corresponds to the items in "sortlist" I don't know if I'm making sense so I'll give an example: if you have a leaderboard (ik its not possible bc of the 128 character limit) you put the scores of the players in "sortlist" and the player names in "sortsidelist" so that way you know who's score is whose
-Quicksort is not my original idea, this is just my implementation of it in Scratch- 2.20.2021: fixed a bug where the "sortsidelist" wasn't scrambled along with the main "sortlist" luckily it only affected lists that where longer than 999 items The Scratch Wiki has a Quicksort script, but it doesn't work for multiple reasons: https://en.scratch-wiki.info/wiki/Sorting_Values The "sort" block in my version is based off it, but I re-wrote some of the 1st hlaf, and all of the 2nd half from Scratch, get it? hehehe, (from the "repeat-until" downwards) The picture on this webpage helps illustrate how Quicksort works: https://deepai.org/machine-learning-glossary-and-terms/quicksort-algorithm still needs some explanation though: "Simply put, the Quicksort algorithm takes a data set and splits it in half at a point known as the "pivot." Each half is then sorted the same way, by each being cut in half. The process is then repeated enough times until the small groups can be sorted easily. In the end, the small groups can be easily ordered to produce a fully sorted data set." I put a detailed explanation in the "explanation sprite" of what the blocks do so go check it out if you're curious The "checkmark" variable that appears is sprite "two" checking if the list is properly sorted, I put it in because it wasn't sorting properly due to some bugs which I've fixed, but I left it in just in case