bogosort


See On Github

Data

Contributor

Generic placeholder thumbnail

by mitogh

in ruby

Source Code

def bogosort(arr)
  arr.shuffle! while arr != arr.sort
  arr
end
require './bogosort.rb'

describe "#bogosort" do
  context "Test empty array" do
    it{ expect(bogosort([])).to eq([]) }
  end

  context "Test to order array" do
    let(:unorder){ [3, 2, 1] } 
    it{ expect(bogosort(unorder)).to eq (unorder.sort) }
  end
end