Implements compare() and swap() methods
* compare(a,b) works like a<=>b
* Swap(i,j) swaps enumerator[i] and enumerator[j]
allows a block to be passed to compare
adds bubble_sort method and allows swap to take an optional third parameter
* bubble_sort works as follows:
** iterate a pointer through the array
** iterate a second pointer from first pointer to end
** swap first pointer and second pointer if first pointer is greater
implements selection_sort
* selection_sort works as follows:
** find index of minimum value of whole array, swap with index 0
** find minimum value of array from index 1 to end, swap with index 1
** repeat to the end
implements insertion_sort
* insertion_sort works as follows:
** start first pointer at index 1
** start second pointer at first pointer
** check element at second pointer against element to its left
*** if they need to be swapped, swap them, move the second pointer accordingly, and check again
*** repeat until either an element does not need to be swapped or it reaches index 0
** iterate first pointer and repeat
Sortable should not extend self (what *should* Sortable.bubble_sort return?)
creates h_sort as a stepping stone to shell_sort
* insertion_sort is now h_sort with h=1
generalizes h_sort to a difference of h items, not 1 item
updates swap(j-1) for swap(j-h)
implements shell_sort
* shell_sort works as follows:
** run an h_sort for large h (~ array.length / 3)
** increment h down by a factor of three and repeat
notifies user that Sortable is built on .map
implements merge_sort
* merge_sort works as follows:
** create an auxilliary array of the same size
** split the array recursively in half as many times as it takes to look at 'small' (~2 element) arrays
** merge those arrays as follows:
*** copy the relevant cells to the auxilliary array
*** break the relevant portion of the auxilliary array in half
*** check the leftmost element of each half
*** write the "smaller" of the two values to the array itself
*** recurse outward with larger and larger sorted chunks
refactor to expose only sort methods, making helper methods private
adds speed test to demonstrate relative efficiency
clarifies usage of this repo in README