function sorted_array = merge_sort(array_to_sort)

	if (length(array_to_sort) <= 1)
	  sorted_array = array_to_sort;
	else
	  mid = floor((1+length(array_to_sort))/2);
	  sorted_array = merge(merge_sort(array_to_sort(1:mid)), ...
	                       merge_sort(array_to_sort(mid+1:end)));
	end   