Passion Fruit!

Vrinda Vasavada's Blog

Mousey’s Cheese Collection: Using Processing to Sort Items!

on June 30, 2014

Objective: To help our class mascot, Mousey, sort his cheesestick collection in the best possible way! Using Insertion Sort, illustrate the animation so that Mousey understands our algorithm as well.

Program: Processing, JavaScript

Steps for Coding:

The easier part of this problem is the sorting algorithm. Insertion sort is an algorithm that checks whether each number is bigger than the others in the list; if so, it inserts that number where it belongs and continues the process until they are all arranged.

insertionsort

After the sorted numbers show in the compiler, it is time to do the animation! We need the rectangles to redraw every time a sort occurs so we use this code in the void setup section.

insertion

Check it out at http://vrindav16.github.io/bubble/index

Smile and wave, Vrinda Vasavada 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: