




import random







def        lowerCAmelCase_			(  snake_case_,snake_case_,snake_case_  ):
						_A							:  List[Any]    =		a[left_index]
						_A							:  Any    =		left_index + 1
						for j in range(left_index + 1,snake_case__  ):
												if a[j] < pivot:
																		_A    ,     _A							:  Tuple    =		a[i], a[j]
																		i += 1
						_A    ,     _A							:  List[str]    =		a[i - 1], a[left_index]
						return i - 1







def        lowerCAmelCase_			(  snake_case_,snake_case_,snake_case_  ):
						if left < right:
												_A							:  List[Any]    =		random.randint(snake_case__,right - 1  )
												_A    ,     _A							:  Optional[int]    =		(
												    a[left],
												    a[pivot],
												)  # switches the pivot with the left most bound
												_A							:  Union[str, Any]    =		partition(snake_case__,snake_case__,snake_case__  )
												quick_sort_random(
												    snake_case__,snake_case__,snake_case__  )  # recursive quicksort to the left of the pivot point
												quick_sort_random(
												    snake_case__,pivot_index + 1,snake_case__  )  # recursive quicksort to the right of the pivot point







def        lowerCAmelCase_			(  ):
						_A							:  Any    =		input("""Enter numbers separated by a comma:\n"""  ).strip()
						_A							:  List[Any]    =		[int(snake_case__  ) for item in user_input.split(""","""  )]

						quick_sort_random(snake_case__,0,len(snake_case__  )  )

						print(snake_case__  )


if __name__ == "__main__":
		main()







import operator







def        lowerCAmelCase_			(  snake_case_,snake_case_ = False,snake_case_ = None  ):
      _A							:  str    =		operator.lt if reverse else operator.gt
      _A							:  Optional[Any]    =		solution or []

      if not arr:
            return solution

      _A							:  Dict    =		[arr.pop(0  )]
      for i, item in enumerate(snake_case_  ):
            if _operator(snake_case_,sublist[-1]  ):
                  sublist.append(snake_case_  )
                  arr.pop(snake_case_  )

    #  merging sublist into solution list
      if not solution:
            solution.extend(snake_case_  )
      else:
            while sublist:
                  _A							:  Union[str, Any]    =		sublist.pop(0  )
                  for i, xx in enumerate(snake_case_  ):
                        if not _operator(snake_case_,snake_case_  ):
                              solution.insert(snake_case_,snake_case_  )
                              break
                  else:
                        solution.append(snake_case_  )

      strand_sort(snake_case_,snake_case_,snake_case_  )
      return solution


if __name__ == "__main__":
  assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
  assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]

