Skip to content

Instantly share code, notes, and snippets.

@whiz25
Created April 24, 2020 08:54
Show Gist options
  • Save whiz25/b86a04a76b1d3a4958180950bbc0fe91 to your computer and use it in GitHub Desktop.
Save whiz25/b86a04a76b1d3a4958180950bbc0fe91 to your computer and use it in GitHub Desktop.
- [ ] bubble_sort_by method is implemented and working (Screenshot from Odin)
- [ ] sorts an array of numbers in increasing order
```ruby
unsorted = (1..10).to_a.reverse!
bubble_sort(unsorted) == unsorted.sort # should return true
```
- [ ] sorts an array by accepting a block
```ruby
unsorted = %w[hi hello hey]
bubble_sort_by(unsorted) { |left, right| left.length - right.length } == %w[hi hey hello] # should return true
```
- [ ] raises an error if block is not given
```ruby
bubble_sort_by(unsorted) == raise_error # should return true
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment