For this project, we created two sorting algorithms that use the bubble sort method.
This side-by-side comparative method is seen in the GIF image below.
The first bubble sort method sorts an array of integers by value, comparing adjacent values with the <=> "spaceship" operator.
The second bubble sort method sorts an array of strings by the length of each element using the "yield" keyword and a code block.
Note: The first algorithm exits once an iteration is passed without any swaps made, signalling that the array is completely sorted. The second algorithm iterates the maximum possible number times (array.length - 1) before exiting. While both methods are suitable for the purposes of this project, it should be noted the first method is better practice in that it does not run code unnecessarily.
- Ruby
- VSCode & Atom
- Rubocop
To quickly see our project in action, visit the live demo on repl.it.
To get this project up and running, you must already have ruby installed on your computer.
To get this project set up on your local machine, follow these simple steps:
-
Open Terminal.
-
Navigate to your desired location to download the contents of this repository.
-
Copy and paste the following code into the Terminal:
-
Hit enter.
-
Once the repository has been cloned, navigate inside the repository and type:
ruby main.rb
This will run the code, printing the output of our tests to the terminal.
-
To change those tests, simply open main.rb in a code editor and modify the values stored in the test_array and test_run variables.
-
Enjoy sorted arrays of data for the rest of your life.
👤 Joseph Burke
- Github: @Joseph-Burke
- Twitter: @__joeburke
- LinkedIn: Joseph Burke
👤 Aye Daniel
- Github: @Alaska01
- Twitter: @AyeAsoo
- Linkedin: Daniel Asoo Aye
The best way you can contribute to this project is by submitting an issue to help us improve it!
If you've read this far, you must like the project! Give us a ⭐️!
- This Project was part of an assignment available on The Odin Project.
- Our thanks to Microverse and all our peers and colleagues there.
This project is MIT licensed.