3ICE's Bucket Sort demonstration


Data

Pseudocode:

myBucketSort(names): buckets = new array[] for each name in the names array: create bucket if first letter is new insert name into buckets[ firstLetterOf(name) ] result = new array[] for each bucket: concatenate bucket into result sort, then return the result

Optimization possibilities

Currently I'm using JavaScript's generic sort() function on the whole data set after bucket sort completes. (The objects are first collected from each bucket.)
Insertion sort would be more efficient here.

The whole code is a big old hack job done in 155 lines of JavaScript, but at least it demonstrates the bucket sort algorithm with neat animations. (Thanks, jQuery!)

Valid HTML5 and CSS3. Works in Chrome, Opera, Firefox, and IE. Safari however, doesn't seem to like me: Slow and two buttons responsible for resetting and prepopulating the textarea kept failing, but I got it to work in the end.)

Created with Notepad++ and Google Chrome, using jQuery, by Daniel "3ICE" Berezvai on 2014. 02. 18.