rootDEV2990 / ruby_bubblesort

Recreating the bubble sort meathod.
1 stars 0 forks source link

Peer to peer code review #2

Open flpfar opened 4 years ago

flpfar commented 4 years ago

Great job, man!

Here are some suggestions:

Keep the great job!!

emiliocm9 commented 4 years ago

def bubble_sort(array) loop do switch = false (array.length - 1).times do |index| if array[index] > array[index += 1] array[index], array[index += 1] = array[index += 1], array[index] switch = true end end break if !switch end array end array = [8,6,2,7,3,4,9] puts bubble_sort(array)