In this project, we built a method #bubble_sort that takes an array and returns a sorted array without using #sort method.
Also, we created a method #bubble_sort_by which sorts an array by accepting a block using yield.
In #bubble_sort_by, the block will have two arguments that represent the two elements of the array that are currently being compared. The block’s return will be similar to the spaceship operator. We implemented the bubble sort algorithm using yield and passing a block to a method.
- About the Project
- Live Demo
- Getting Started
- Authors
- Contributing
- Show your support
- License
- Acknowledgements
To get a local copy up and running follow these simple example steps.
- On the project GitHub page, navigate to the main page of the repository.
- Under the repository name, locate and click on a green button named
Code
. - Copy the project URL as displayed.
- If you're running the Windows Operating System, open your command prompt. On Linux, Open your terminal.
- Change the current working directory to the location where you want the cloned directory to be made. Leave as it is if the current location is where you want the project to be.
- Type git clone, and then paste the URL you copied in Step 3.
e.g. $ git clone https://github.com/yourUsername/yourProjectName - Press Enter. Your local copy will be created.
- Type pry, and load the file like below:
load "bubble_sort.rb"
- Call methods on the pry and try it.
👤 Yoko Saka
👤 Divyesh Patel
- GitHub: @Div685
- Twitter: @div_685
- LinkedIn: Divyesh Patel
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Give a ⭐️ if you like this project!
This project is MIT licensed.