I am working on a program that takes a list and sorts it from highest to lowest [Yes I know I could use .sort()]. The program is the following:
UnList = raw_input("Enter a list of numbers seperated by commas") #collects the users list
List = UnList.split(",") #Turns the users numbers into a list
for x in range(len(List)): #number of time to sort
Switcher = 0 #the switcher (also will reset it later)
for z in range(len(List)-1): #number of time the switcher runs
if List[Switcher] > List[(Switcher + 1)]: #if one number is bigger than the other
List[Switcher],List[(Switcher+1)] = List[(Switcher+1)],List[Switcher] #this switches those 2 numbers
Switcher += 1 #adds to the switcher
print "The new list is:", List #prints the output
Sometimes it works, as in with the example "1,7,4,6,3" Other times, such as with "-10,5,4,32,4,-40,2" it gives the completely incorrect output "['-10', '-40', '2', '32', '4', '4', '5']"
-10appears before-40