예제 #1
0
def sort(data):

	outsideLoopCount=0
	swapCount=0
	swapped = True 
	length = len(data)

	while swapped:

		j = 0
		outsideLoopCount += 1
		swapped = False

		while j + 1 < length:

			if data[j] > data[j+1]:
				swapCount += 1
				data = support.swap(data, j, j+1)
				swapped = True

			j += 1

#	print "Outside loop count: ", outsideLoopCount
#	print "Swap count: ", swapCount 
	return data
예제 #2
0
def sort(data):

	j=1
	outsideLoopCount=0
	swapCount=0
	length = len(data)

	while j <= length -1:
		
		k = 0
		outsideLoopCount += 1

		while k < j:

			if data[k] > data[j]:
				data = support.swap(data, k, j)
				swapCount += 1

			k += 1

		j += 1

#	print "Outside loop count: ", outsideLoopCount
#	print "Swap count: ", swapCount 
	return data
예제 #3
0
def sort(data):

	j=0
	outsideLoopCount=0
	swapCount=0

	swapped = True 
	length = len(data)

	while j <= length -1:

		k = j + 1
		smallest = data[j]
		outsideLoopCount += 1

		while k <= (length - 1):

			if data[k] < smallest:
				smallIndex = k
				smallest = data[k]

			k += 1

		for l in range(0, j+1):

			if data[l] > smallest:
				data = support.swap(data, l, smallIndex)
				swapCount += 1

		j += 1

#	print "Outside loop count: ", outsideLoopCount
#	print "Swap count: ", swapCount 
	return data
예제 #4
0
def sort_schedule(missions, times_text, status):  # simple sort
    n = len(times_text)
    times = n * [0]
    # Get all times type number ----
    for i in range(n):
        time_text = times_text[i].split("-")[0]
        times[i] = sp.convertTimeToSecond(time_text)

    for i in range(n):
        for j in range(i + 1, n):
            if times[i] > times[j]:
                (times[i], times[j]) = sp.swap(times[i], times[j])
                (times_text[i],
                 times_text[j]) = sp.swap(times_text[i], times_text[j])
                (missions[i], missions[j]) = sp.swap(missions[i], missions[j])
                (status[i], status[j]) = sp.swap(status[i], status[j])

    return missions, times_text, status