I am trying to sort a list of random integer values like so: aList = [2241, 350]
by starting at the last element in each individual integer (after converting the integer to a string) 241, and 350 and sorting into empty lists like so:
zeros = [350]
ones = [2241]
twos = []
threes = []
fours = []
fives = []
sixes = []
sevens = []
eights = []
nines = []
then returning a combined list like so: aList = [350, 2241]
and iterating over it again to look at the next value in the integer and repeat the process until the list is sorted from smallest to largest integer.
This is my code so far:
zeros, ones, twos, threes, fours, fives, sixes, sevens, eights, nines = [], [], [], [], [], [], [], [], [], []
for x in range(-1, 0) :
for val in aList :
val = str(val)
if val[x] == 0 :
zeros.append(val)
elif val[x] == 1 :
ones.append(val)
elif val[x] == 2 :
twos.append(val)
elif val[x] == 3 :
threes.append(val)
elif val[x] == 4 :
fours.append(val)
elif val[x] == 5 :
fives.append(val)
elif val[x] == 6 :
sixes.append(val)
elif val[x] == 7 :
sevens.append(val)
elif val[x] == 8 :
eights.append(val)
elif val[x] == 9 :
nines.append(val)
aList = zeros + ones + twos + threes + fours + fives + sixes + sevens + eights + nines
del zeros[:], ones[:], twos[:], threes[:], fours[:], fives[:], sixes[:], sevens[:], eights[:], nines[:]
return aList
which returns an empty list. Any help is appreciated, thanks.