[Collaborative project]
In this project, we implemented the bubble sort algorithm. The assignment is focused on the use of yield and passing a block to a method.
The next part of the assignment is similar to the previous method, but it accepts code blocks using yield.
- Ruby
Ruby installed.
-
Bubble Sort [bubble_sort.rb] — buble_sort method accept one argument(array)
To test code you can provide following line at the end of the code
p bubble_sort([4, 3, 78, 2, 0, 2])
and then run from terminal
foo:$ ruby bubble_sort.rb
-
In this case, it receives a block of code and uses yield in method to execute the descending sort
To test the code, you can provide the following line at the end of the code.
sorted_by_array = bubble_sort_by(%w[hi hello hey]) do |left, right| left.length - right.length end p sorted_by_array
and then run from terminal
foo:$ ruby bubble_sort_by.rb
To get a local copy up and running follow these simple example steps.
- Go to https://github.com/ShinobiWarior/Bubble-sort
- Click on the code button and copy the HTTPS/ SSH URL.
- On terminal, type
git clone
command followed by pasting HTTPS/ SSH URL to clone this repository on your local machine. - Run
git checkout -b your-branch-name
. Make your contributions - Push your branch up to your forked repository
- Open a Pull Request with a detailed description of the development branch of the original project for a review
👤 Aleksandar Ivezic
- GitHub: Aleksandar Ivezic
- Twitter: @Aivezic
- LinkedIn: Aleksandar Ivezic
👤 Moises Hernandez
- GitHub: @githubhandle
- Twitter: @twitterhandle
- LinkedIn: LinkedIn
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.