def bitonic_sort(arr, reverse=False):
def compare(arr, reverse):<EOL><INDENT>n = len(arr)//<NUM_LIT:2><EOL>for i in range(n):<EOL><INDENT>if reverse != (arr[i] > arr[i+n]):<EOL><INDENT>arr[i], arr[i+n] = arr[i+n], arr[i]<EOL><DEDENT><DEDENT>return arr<EOL><DEDENT>def bitonic_merge(arr, reverse):<EOL><INDENT>n = len(arr)<EOL>if n <= <NUM_LIT:1>:<EOL><INDENT>return arr<EOL><DEDENT>arr = compare(arr, reverse)<EOL>left = bitonic_merge(arr[:n // <NUM_LIT:2>], reverse)<EOL>right = bitonic_merge(arr[n // <NUM_LIT:2>:], reverse)<EOL>return left + right<EOL><DEDENT>n = len(arr)<EOL>if n <= <NUM_LIT:1>:<EOL><INDENT>return arr<EOL><DEDENT>if not (n and (not(n & (n - <NUM_LIT:1>))) ):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>left = bitonic_sort(arr[:n // <NUM_LIT:2>], True)<EOL>right = bitonic_sort(arr[n // <NUM_LIT:2>:], False)<EOL>arr = bitonic_merge(left + right, reverse)<EOL>return arr<EOL>
bitonic sort is sorting algorithm to use multiple process, but this code not containing parallel process
It can sort only array that sizes power of 2
It can sort array in both increasing order and decreasing order by giving argument true(increasing) and false(decreasing)

Worst-case in parallel: O(log(n)^2)
Worst-case in non-parallel: O(nlog(n)^2)

reference: https://en.wikipedia.org/wiki/Bitonic_sorter