Welcome! As a budding Rubyist, I wanted to work on my Ruby chops and dive into algorithms. I noticed a dearth of well-documented Ruby examples, so I made some myself. Hopefully this will be helpful to someone looking to get started in sorting algorithms and/or Ruby. I am aware there is a sort method, but like most things I wanted to pick it apart and see how it worked. I'd love feedback on some more clever ways to do these.
Mike August 2011
- Bubble Sort
- Selection Sort
- Insertion Sort (coming soon)
- Quick Sort (coming soon)
"A selection sort finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list."
Ruby implementation of the infamously inefficient "Bubble Sort"
Sorting Algorithms - Bubble Sort (now with hot animated sorting action)
- Added the ability to stop once the array is sorted, rather than stepping through every set of elements all the time. Cleaned it up with methods and a Class. Commented the line to see each iteration printed out.
======= 8/17/11 - Bubble Sort v1.0
Cheers!
Mike Manewitz mike.manewitz@gmail.com