Sorting algorithms/Bubble sort: Difference between revisions

Content deleted Content added
Line 113: Line 113:
This sort is actually a C quicksort.
This sort is actually a C quicksort.


Although the native Ruby sort method for Arrays if much faster (O(n*log(n)) versus O(n**2)), you can find a Ruby version of Bubble sort hereunder. It adds the sort! method to the Array object, making it readily available for all Array objects
Although the native Ruby sort method for Arrays if much faster (O(n*log(n)) versus O(n**2)), you can find a Ruby version of Bubble sort hereunder. It adds the sort! method to the Array object (overwriting the already existing sort! method), making it readily available for all Array objects
class Array
class Array
def sort!
def sort!