示例#1
0
def oddEven(x, conn):
	is_sorted = False
	con = random.choice(conn)
	while not is_sorted:
		is_sorted = True
		for i in range(0, len(x)-1, 2):
			if compare.left_is_smaller(x[i+1], x[i], con[0]):
				x[i], x[i+1] = x[i+1], x[i]
				is_sorted = False
		for i in range(1, len(x)-1, 2):
			if compare.left_is_smaller(x[i+1], x[i], con[0]):
				x[i], x[i+1] = x[i+1], x[i]
				is_sorted = False
	return x
示例#2
0
def bubble(list, connn, inactive_clients):
	for i in range(len(list) - 1, 0, -1):
		for b in range(0, i):
			if compare.left_is_smaller(list[b], list[b + 1], connn, inactive_clients):
				pass
			else:
				list[b], list[b + 1] = list[b + 1], list[b]
	return list
示例#3
0
def swapping(tosort, start, conn):
	for i in range(start, len(tosort) - 1, 2):
		if compare.left_is_smaller(tosort[i], tosort[i + 1], conn):
			tosort[i], tosort[i + 1] = tosort[i + 1], tosort[i]
			listret = [tosort, False]
			return listret
		else:
			listret = [tosort, True]
			return listret
	return
示例#4
0
def quick(list, conn, inactive_clients):
	if len(list) <= 1:
		return list
	list1 = []
	list2 = []
	pivot = random.choice(list)
	for number in list:
		if compare.left_is_smaller(pivot, number, conn, inactive_clients):
			list2.append(number)
		else:
			list1.append(number)
	return quick(list1, conn, inactive_clients) + quick(list2, conn, inactive_clients)