Skip to content

Instantly share code, notes, and snippets.

View dev-nyc's full-sized avatar
🤹‍♂️
pushing

khaled dev-nyc

🤹‍♂️
pushing
View GitHub Profile
@dev-nyc
dev-nyc / sort.rb
Created October 25, 2016 19:07 — forked from aspyct/sort.rb
Sample implementation of quicksort, mergesort and binary search in ruby
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end
I reviewed some common Ruby methods and grouped them by behavior.
Hopefully this helps someone else too.
[Please copy paste and fix typos, add/delete, improve from this Gist.](https://gist.github.com/dirkdirk/9209d7ea67ac57543975162713910224)
-
# Array