bubble_sort method that accepts an unsorted array and returns a sorted array.
bubble_sort_by method that accepts an unsorted array and returns sorted array by sorting based on the comparison provided in a block using yield method.
- Clone the repo
- Open the repo in terminal window
- Install ruby and pry
- Open pry
- Run the following comand
load "_bubble_sort.rb"
- Call the methods with an array as parameter as shown in the example below
- Example
bubble_sort([4,3,78,2,0,2])
=> [0,2,2,3,4,78]
bubble_sort_by(["hi","hello","hey"]) do |left,right|
left.length - right.length
end
=> ["hi", "hey", "hello"]
- Ruby
👤 Binyam Hailemeskel
- GitHub: @bini-i
- Twitter: @binyamshewa
- LinkedIn: LinkedIn
👤 Dibyendu Das
- GitHub: @DibDas
- Twitter: @DIBYEND78120480
- LinkedIn: Dibyendu Das
Contributions, issues, and feature requests are welcome!
Give a ⭐️ if you like this project!
- Ruby docmentation
- Ruby Guides
This project is MIT licensed.