Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


The partition function takes the last element in the array as the pivot, places the pivot element at correct position in sorted array, and places elements smaller than pivot to the left of pivot and elements greater than pivot to the right of pivot. And it returns the partitioning index used as new pivots in recursive quicksort.
The quicksort sorts the left and right sub-arrays about the pivot.

I used a boolean variable asc to control the order of sorting.

Please look at my comments in the ext1.rb file for more detailed explanation.


Image Removed

My program is able to sort any type of array in ascending or descending order.

Image Added