Created
July 24, 2019 09:16
-
-
Save kelvin8773/b5097b9afc12cf01a10b88f03fe53d12 to your computer and use it in GitHub Desktop.
Revisions
-
kelvin8773 created this gist
Jul 24, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ def advanced_quicksort(array) def helper(array, start=0, last=array.size-1) return array if last-start < 1 pivot = array[last] middle = start - 1 for i in start..last array[i] <= pivot ? (middle += 1; array[i], array[middle] = array[middle], array[i] ) : array[i] end # puts array.join(" ") helper(array, start, middle-1) helper(array, middle+1, last) end result = array.dup helper(result) end