Skip to content

This is a demonstration to bubble sort algorithm using Ruby

License

Notifications You must be signed in to change notification settings

jstloyal/Bubble_sort

Repository files navigation

Demonstration of The Bubble Sort Algorithm

A demonstration of bubble-sort method which sorts in ascending mode the elements of a collection using Ruby language. This is a project of the Microverse Ruby Course.

Contributors Forks Stargazers Issues


Microverse Logo

Bubble Sort

This project is part of the Microverse curriculum in Ruby module!
Explore the docs »

View Demo Report Bug Request Feature

Table of Contents

About The Project

The project consists of three code files

  • bubble_sort.rb Contains the method bubble_sort. The bubble_sort methods accepts either an array of numbers and sorts them according to their value in ascending order or an array of strings and sorts them in ascending order alphabetically. An error occurs if the method is passed an array with mixed numbers and strings.

  • bubble_sort_by.rb Contains the method bubble_sort_by. The bubble_sort_by method accepts an array of strings and sorts them according to their size (length) in ascending order. Also, it uses a block to manage the sorting procedure which is called-back by a yield statement inside the method. An error occurs if the method is passed an array of numbers.

  • test.rb Contains test code for the two methods.

Testing

You may test the code either by running the test.rb file using Ruby or provide your own array such as

  • for bubble_sort [10, 9, 5, 2, 3, 4] or [5.45, 3.1, 3, 2, 1]
  • for bubble_sort_by ['avalon', 'beta', 'con'] Please note, the method bubble_sort_by requires a block of the form {|x, y| x <=> y}.

Built With

This project was built using these technologies.

  • Ruby
  • Rubocop
  • VsCode

Live version

You can see it working Run on Repl.it

Contributors

👤 Author_1 ​## Adetayo Sunkanmi

👤 Author_2 ​## Ioannis Kousis

Acknowledgements

License

📝 This project is MIT licensed.

About

This is a demonstration to bubble sort algorithm using Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages