[Python][QuickSort] Quick sort with random partition
Quick sort with random parition to make the sorting faster and to handle the worst case (when all elements are already sorted)\n\n\nclass Solution:\n    def sor
Quick sort with random parition to make the sorting faster and to handle the worst case (when all elements are already sorted)\n\n```\nclass Solution:\n    def sortArray(self, nums: List[int]) -> List[int]:\n        self.quicksort(nums, 0, len(nums)-1)\n        return nums\n    \n    def quicksort(self, nums, start, end):\n        if start >= end:\n            return\n        \n        part = self.part(nums, start, end) # partition the array\n        self.quicksort(nums, start, part-1)\n        self.quicksort(nums, part+1, end) # dont include the parition idx itself since left..... idx......right\n    \n    def part(self, nums, left, right):\n        idx = left\n        ran = randint(left, right)\n        nums[right], nums[ran] = nums[ran], nums[right]\n        pivot = nums[right]\n        \n        for i in range(left, right):\n            if nums[i] <= pivot:\n                nums[idx],nums[i] = nums[i], nums[idx]\n                idx+=1\n        \n        nums[idx],nums[right] = nums[right], nums[idx]\n        return idx # return the idx for part\n```
['Sorting', 'Python']