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.
My program is able to sort any type of array in ascending or descending order.