






from multiprocessing import Lock, Pipe, Process

# lock used to ensure that two processes do not access a pipe at the same time
__lowerCamelCase	:		Tuple										=   Lock()







def 			A__							(      _a  :					List[Any]		,  _a  :					List[Any]		,  _a  :					Optional[int]		,  _a  :					Optional[Any]		,  _a  :					Optional[int]		,  _a  :					Any		,  _a  :					int	):





 '''simple docstring'''







 global process_lock

 # we perform n swaps since after n swaps we know we are sorted
 # we *could* stop early if we are sorted already, but it takes as long to
 # find out we are sorted as it does to sort the list with this algorithm
 for i in range(0		,  10	):
  if (i + position) % 2 == 0 and r_send is not None:
   # send your value to your right neighbor
   process_lock.acquire()
   r_send[1].send(_a	)
   process_lock.release()

   # receive your right neighbor's value
   process_lock.acquire()
   snake_case__  :    List[Any]							       =rr_cv[0].recv()
   process_lock.release()

   # take the lower value since you are on the left
   snake_case__  :    Tuple							       =min(_a		,  _a	)
  elif (i + position) % 2 != 0 and l_send is not None:
   # send your value to your left neighbor
   process_lock.acquire()
   l_send[1].send(_a	)
   process_lock.release()

   # receive your left neighbor's value
   process_lock.acquire()
   snake_case__  :    List[Any]							       =lr_cv[0].recv()
   process_lock.release()

   # take the higher value since you are on the right
   snake_case__  :    Dict							       =max(_a		,  _a	)
    # after all swaps are performed, send the values back to main
 result_pipe[1].send(_a	)







def 			A__							(      _a  :					Dict	):





 '''simple docstring'''







 snake_case__  :    int							       =[]
 snake_case__  :    Dict							       =[]
 # initialize the list of pipes where the values will be retrieved
 for _ in arr:
  result_pipe.append(Pipe()	)
 # creates the processes
 # the first and last process only have one neighbor so they are made outside
 # of the loop
 snake_case__  :    Optional[Any]							       =Pipe()
 snake_case__  :    Any							       =Pipe()
 process_array_.append(
     Process(
         target=_a		,  args=(0, arr[0], None, temp_rs, None, temp_rr, result_pipe[0])		,  )	)
 snake_case__  :    Any							       =temp_rs
 snake_case__  :    str							       =temp_rr

 for i in range(1		,  len(_a	) - 1	):
  snake_case__  :    Union[str, Any]							       =Pipe()
  snake_case__  :    Optional[Any]							       =Pipe()
  process_array_.append(
      Process(
          target=_a		,  args=(i, arr[i], temp_ls, temp_rs, temp_lr, temp_rr, result_pipe[i])		,  )	)
  snake_case__  :    str							       =temp_rs
  snake_case__  :    Optional[int]							       =temp_rr

 process_array_.append(
     Process(
         target=_a		,  args=(
             len(_a	) - 1,
             arr[len(_a	) - 1],
             temp_ls,
             None,
             temp_lr,
             None,
             result_pipe[len(_a	) - 1],
         )		,  )	)

 # start the processes
 for p in process_array_:
  p.start()

 # wait for the processes to end and write their values to the list
 for p in range(0		,  len(_a	)	):
  snake_case__  :    List[str]							       =result_pipe[p][0].recv()
  process_array_[p].join()
 return arr







def 			A__							(      ):





 '''simple docstring'''







 snake_case__  :    Any							       =list(range(10		,  0		,  -1	)	)
 print("""Initial List"""	)
 print(*_a	)
 snake_case__  :    Dict							       =odd_even_transposition(_a	)
 print("""Sorted List\n"""	)
 print(*_a	)


if __name__ == "__main__":
       main()













import math







def 			A__							(      _a  :					list		,  _a  :					int = 0		,  _a  :					int = 0	):





 '''simple docstring'''







 snake_case__  :    Tuple							       =end or len(_a	)
 for i in range(_a		,  _a	):
  snake_case__  :    int							       =i
  snake_case__  :    int							       =array[i]
  while temp_index != start and temp_index_value < array[temp_index - 1]:
   snake_case__  :    Dict							       =array[temp_index - 1]
   temp_index -= 1
  snake_case__  :    Dict							       =temp_index_value
 return array







def 			A__							(      _a  :					list		,  _a  :					int		,  _a  :					int	):  # Max Heap





 '''simple docstring'''







 snake_case__  :    Tuple							       =index
 snake_case__  :    Dict							       =2 * index + 1  # Left Node
 snake_case__  :    Union[str, Any]							       =2 * index + 2  # Right Node

 if left_index < heap_size and array[largest] < array[left_index]:
  snake_case__  :    Dict							       =left_index

 if right_index < heap_size and array[largest] < array[right_index]:
  snake_case__  :    List[Any]							       =right_index

 if largest != index:
  snake_case__       ,   snake_case__  :    List[Any]							       =array[largest], array[index]
  heapify(_a		,  _a		,  _a	)







def 			A__							(      _a  :					list	):





 '''simple docstring'''







 snake_case__  :    List[str]							       =len(_a	)

 for i in range(n // 2		,  -1		,  -1	):
  heapify(_a		,  _a		,  _a	)

 for i in range(n - 1		,  0		,  -1	):
  snake_case__       ,   snake_case__  :    Tuple							       =array[0], array[i]
  heapify(_a		,  0		,  _a	)

 return array







def 			A__							(      _a  :					list		,  _a  :					int		,  _a  :					int		,  _a  :					int	):





 '''simple docstring'''







 if (array[first_index] > array[middle_index]) != (
     array[first_index] > array[last_index]
 ):
  return array[first_index]
 elif (array[middle_index] > array[first_index]) != (
     array[middle_index] > array[last_index]
 ):
  return array[middle_index]
 else:
  return array[last_index]







def 			A__							(      _a  :					list		,  _a  :					int		,  _a  :					int		,  _a  :					int	):





 '''simple docstring'''







 snake_case__  :    Dict							       =low
 snake_case__  :    Union[str, Any]							       =high
 while True:
  while array[i] < pivot:
   i += 1
  j -= 1
  while pivot < array[j]:
   j -= 1
  if i >= j:
   return i
  snake_case__       ,   snake_case__  :    List[Any]							       =array[j], array[i]
  i += 1







def 			A__							(      _a  :					list	):





 '''simple docstring'''







 if len(_a	) == 0:
  return array
 snake_case__  :    Optional[int]							       =2 * math.ceil(math.loga(len(_a	)	)	)
 snake_case__  :    Tuple							       =16
 return intro_sort(_a		,  0		,  len(_a	)		,  _a		,  _a	)







def 			A__							(      _a  :					list		,  _a  :					int		,  _a  :					int		,  _a  :					int		,  _a  :					int	):





 '''simple docstring'''







 while end - start > size_threshold:
  if max_depth == 0:
   return heap_sort(_a	)
  max_depth -= 1
  snake_case__  :    Dict							       =median_of_a(_a		,  _a		,  start + ((end - start) // 2) + 1		,  end - 1	)
  snake_case__  :    List[str]							       =partition(_a		,  _a		,  _a		,  _a	)
  intro_sort(_a		,  _a		,  _a		,  _a		,  _a	)
  snake_case__  :    Union[str, Any]							       =p
 return insertion_sort(_a		,  _a		,  _a	)


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       __lowerCamelCase	:		Optional[int]										=   input("""Enter numbers separated by a comma : """).strip()
       __lowerCamelCase	:		Dict										=   [float(item) for item in user_input.split(""",""")]
       print(sort(unsorted))





