I have an assignment, where I'm to sort a list from low to high. But my program gives out an inverse of the expected order. This is my futile attempt at the assignment. Please help me I am genuinely stuck. Hopefully it is a noob mistake.
from random import *
def main():
# initializing variables
numList = []; #the list of integers
numListLength = 25; #the number of integers in numList array
maxShuffles = 1000; #the number of times numList is to be shuffled
#populating numList
while len(numList) < numListLength :
randomElement = randint(-100, 100)
numList.append(randomElement)
printNow("List before shuffling: " )
printNow(numList)
#shuffle the list multiple times
shuffleCount = 0
while shuffleCount < maxShuffles :
i = randrange( 0, len(numList) )
j = randrange( 0, len(numList) )
if i < j :
#compare the contents of those locations
if numList[i] < numList[j] :
#swap the contents
original_i = numList[i]
original_j = numList[j]
numList[i] = original_j
numList[j] = original_i
elif j < i :
if numList[j] < numList[i] :
#swap the contents
original_i = numList[i]
original_j = numList[j]
numList[i] = original_j
numList[j] = original_i
#increment shuffleCounter
shuffleCount = shuffleCount + 1
#shuffling done, display results
printNow("List after shuffling: ")
printNow(numList)
main()