Sort arrays using different sorting techniques
gem install sortech
or add it to your gemfile:
gem 'sortech'
and run bundle install
require 'sortech'
arr = Array.new(20){rand(1..100000)}.shuffle
puts "Original Array: "
arr.each{|item| p item}
arr = Sortech::Sort.bubble(arr)
puts "Sorted Array: "
arr.each{|item| p item}
- Bubble sort (Sortech::Sort.bubble)
- Selection sort (Sortech::Sort.selection)
- Insertion sort (Sortech::Sort.insertion)
- Quick Sort (Sortech::Sort.quicksort)
- Merge Sort (Sortech::Sort.mergesort)