# Sorting algorithm simulator thingy

Enter the data size, then press space to start.
It takes longer the larger your data is.
Edit: Added "double bubble", which is a failed attempt to add comb sort bubble with two pointers. Exciting!

Nice, this is pretty cool!
I still don't understand how it works, though.

Nice visualization. And I love how you use the SORT block to randomize the data! (Although you're kind of lucky it worked; it's not obvious that a sort algorithm will terminate if its comparator isn't a function.) I wonder if it would be easier to see the algorithm if, when you swap two values, their positions could GLIDE to each other's starting position. (I know, the vertical bars aren't sprites, but you could have just two sprites, a little thicker than the drawn bars, to enact each swap.)

Why does everyone except me like bubble sort so much?

The next step would be to have a choice of sorting algorithms, so you could show a mergesort for example.

Well, yes. :~) It's funny that you felt a need to say that!

The moving green bar is the current position of the algorithm. It goes through the list, and if it finds a misplaced item, it puts that item where it's supposed to be. This is repeated until the list is sorted.

I said that mostly because of the green animation at the end, which can be boringly long, and I couldn't find any way to speed it up. (I think I have an idea though.)

I originally made it bubble sort, but, again, it was boringly slow and I couldn't find a way to speed it up. So I changed it to... this? If anyone knows the name of this algorithm, please tell me.

Oh, wait, this isn't bubble sort? It repositions the out-of-place value by already knowing where that value belongs? That's cheating! What makes sorting hard is that the algorithm can't know where a value "belongs" until all the other values are in place also.

Ah, noted...
Edit: I'm changing it to bubble sort, because I can't figure out how to make the current version cheating-free. There will be more types of algorithms in the future.

Good job

You can do this to make things clearer for the user.

optimization tip:
you don't have to go through the whole list at every pass: 1st pass all the data, 2nd pass (data length -1) pass, 3rd pass (data length - 2) pass, etc (because the last records are already sort by the previous pass..)

here's a remix of your idea

i've used a modified version of the plot block from the frequency distribition analist library

I would, but I'm planning to implement a lot more algorithms, and eventually the ask box would run out of space.
I'll do something similar though.

Thanks!