added ruby bubble_sort example (#33907)

* added ruby bubble_sort example

* fix: corrected code block syntax

* fix: fixed typo and used 2 space indentation
This commit is contained in:
chrisgithubok
2019-06-27 13:20:31 -07:00
committed by Randell Dawson
parent 5c51c407c0
commit 3e175e52b3

View File

@ -51,7 +51,6 @@ Now, the array is already sorted, but our algorithm does not know if it is compl
### Video Explanation
[Bubble sort in easy way](https://www.youtube.com/watch?v=Jdtq5uKz-w4)
-----
### Example in JavaScript
```js
@ -159,6 +158,22 @@ def bubbleSort(arr):
```
### Example in Ruby
```ruby
def bubble_sort(arr)
sorted = false
until sorted
sorted = true
(arr.count-1).times do|i|
if arr[i] > arr[i + 1]
arr[i], arr[i +1] = arr[i +1], arr[i]
sorted = false
end
end
end
arr end
```
### Example in PHP
```php