Example #1
0
def sort(sequence):
	size = len(sequence)

	if size < merge.CUTOFF:
		merge.insertion_sort(sequence)
		return
	
	auxiliary = sequence[:]
	bucket = 1
	while bucket < size:
		first = 0
		middle = bucket
		last = middle + bucket
		while first < size:
			middle = middle if middle <= size else size
			last = last if last <= size else size
			merge.merge(auxiliary, sequence, first, middle, last)
			first = last
			middle = first + bucket
			last = middle + bucket
		sequence, auxiliary = auxiliary, sequence
		bucket *= 2
	return sequence
Example #2
0
def sort(sequence):
	if len(sequence) < merge.CUTOFF:
		merge.insertion_sort(sequence)
	else:
		_sort(sequence, sequence[:], 0, len(sequence))