Skip to content

Instantly share code, notes, and snippets.

View dgreenbe77's full-sized avatar

Daniel Greenberg dgreenbe77

  • Hirefrederick, Inc.
  • San Francisco, CA
View GitHub Profile
@aspyct
aspyct / sort.rb
Last active April 3, 2025 12:24
Ruby implementation of quicksort, mergesort and binary search
# 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