Skip to content

bini-i/Bubble-Sort

Repository files navigation

Bubble Sort

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.

screenshot

How to use this repo?

  • 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"]

Live Demo

Live Demo Link

Built With

  • Ruby

Authors

👤 Binyam Hailemeskel

👤 Dibyendu Das

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

📝 License

This project is MIT licensed.

About

Sorting methods using bubble sort algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages