Skip to content

One of the simpler ways of sorting a group of items in an array is bubble sort. And we are doing it on our project.

License

Notifications You must be signed in to change notification settings

kubilaycaglayan/bubble-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hire-badge Twitter Follow

hire-badge Twitter Follow

Bubble-Sort-Algorithm

One of the simpler ways of sorting a group of items in an array is bubble sort. We are re-creating this method in our project.

You will find two functions in our code:

  1. bubble_sort Function that sorts a given array of numbers.
  2. bubble_sort_by Function that sorts a given array of items. It accepts blocks that compares items in the array by using yield method and return value of the block.

Both of them optimized with two optimizations:

  1. Decreasing number of iteration for each round.
  2. Swap check: break if not swapped.

Built With

  • Ruby

Live Demo

Live Demo Link

Getting Started

To get a local copy up and running follow these steps:

Prerequisites

  • Ruby installed on local machine
  • A browser (for usage or repl.it)

Usage

Preview with repl.it in Live Demo Link

OR:

  • Fork/Clone this project to your local machine
  • Open bubble_sort.rb in your local enviroment and run this code:
## Testing bubble_sort

p t_array = [4, 3, 78, 2, 0, 2]
p bubble_sort(t_array)


## Testing bubble_sort_by

p bubble_sort_by(%w[hi hello hey]) do |left, right|
  left.length - right.length
end

Authors

👤 Ikraam Ghoor

👤 Kubilay Caglayan

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page

Start by:

  • Forking the project
  • Cloning the project to your local machine
  • cd into the project directory
  • 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 to the development(or master if not available) branch of the original project for a review

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

  • The Odin project for the project plan

📝 License

This project is MIT licensed

About

One of the simpler ways of sorting a group of items in an array is bubble sort. And we are doing it on our project.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages