I wrote the following code in Python. It does not sort the list. Can anyone help me out?
theList = []
def simpleSort():
pos = 1
comps = 0
while pos < len(theList):
comps += 1
if ord(theList[pos]) >= ord(theList[pos - 1]):
pos += 1
else:
temp = theList[pos]
print(theList[pos])
theList[pos] = theList[pos - 1]
print(theList[pos])
theList[pos - 1] = temp
if pos == 1:
pos += 1
else:
pos -= 1
return comps
def main():
fileName = input("Type a filename: ")
aFile = open(fileName)
for line in aFile:
theList = line.split()
print("Original List:")
print(theList)
comps = simpleSort()
print("Sorted List:")
print(theList)
print("Compares:")
print(comps)
main()