Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.
Explanation on how bubble sort works can be well illustrated by below gif image:
In this project, there are two methods bubble_sort
and bubble_sort_by
.
bubble_sort
method sorts the array of integers in ascending order.bubble_sort_by
method sorts the array of strings in ascending order based on the number of characters in the string.
- Ruby
Just clone this repo and and navigate to the folder.
To get a local copy up and running follow these simple example steps.
- Clone this repo.
- Navigate to the bubble_sort folder
- In your terminal run
ruby main.rb
- You are successful to get a local copy up and running.
π€ David Bassey
- GitHub: @davidosky007
- Twitter: @davidosky2
- LinkedIn: David Bassey
π€ Uchenna Anya
- GitHub: @uchennaanya
- Twitter: @martinsanya19
- LinkedIn: uchenna anya
Contributions, issues, and feature requests are welcome!
Give a βοΈ if you like this project!
- Bubble sort explanation gif image downloaded from Wikipedia
- the odin project
This project is MIT licensed.