Please let me know if I should make something more clear
1. Each item in list contains a tuple with its name -> ((value, work), 'name')
2. the function "sort" below sorts the list of subjects by "value" in descending order
3. I get: TypeError: 'int' object is unsubscriptable (occurs after looping a few times)
It shouldn't be the logic of the sorting method as it works elsewhere
Could the problem be due to how the list is created? (see under sort function)
def sortj(list):
for i in range(1, len(list)):
value = list[ i ][ 0 ][ 0 ] ## integer
j = i - 1
done = False
while not done:
if value > list[ j ][ 0 ][ 0 ]: # error occurs ( list [ j ] [ 0 ] [ 0 ] is the problem)
list[ j + 1 ] = list[ j ]
j -= 1
if j < 0:
done = True
else:
done = True
list[ j + 1 ] = value
after list is created by the following process, the sorting above is attempted
(Why does the first item appear to be an empty list in the finished product of "sortedj" ?)
# this is gathering the tuples that contain j amount of work from a list of subjects in a dictionary
for j in workCaps: # the range of max work
sortedj = []
for i in subIndexes:
if j <= maxWork:
if subjects[names[i]][1] == j: ## if work =
sortedj.append((subjects[names[i]], names[i]))
Thanks for any help