from random import randint
import sys

def sort_and_count(arr):
	n = len(arr)

	if n == 1:
		return 0

	else:
		first_half = sort_and_count(arr[:n/2])
		second_half = sort_and_count(arr[n/2:])
		split = merge_and_count_split(arr)
		return first_half + second_half + split


def merge_and_count_split(arr):
	return 0

def main(arr_len):
	test_arr = [randint(0,arr_len) for n in range(arr_len)]
	return sort_and_count(test_arr)

if __name__ == '__main__':
	try:
		arr_len = int(sys.argv[1])
	except (IndexError, ValueError):
		print 'Format: python merge-sort.py <array-length>'

	print main(arr_len)
@@ -114,39 +114,24 @@
 irst_half = 
-sort_and_count(
 arr%5B:n/2%5D)%0A%09
@@ -127,17 +127,16 @@
 rr%5B:n/2%5D
-)
 %0A%09%09secon
@@ -144,31 +144,16 @@
 _half = 
-sort_and_count(
 arr%5Bn/2:
@@ -157,19 +157,17 @@
 /2:%5D
-)
 %0A%09%09
-split =
+return
  mer
@@ -189,35 +189,51 @@
 lit(
-arr)%0A%09%09return first_half + 
+sort_and_count(first_half), sort_and_count(
 seco
@@ -243,16 +243,10 @@
 half
- + split
+))
 %0A%0A%0Ad

Implement sort_and_count