Sorting a Two Dimensional List in python using Insertion Sort -


so want sort list of namedtuples using insertion sort in python, , here code.

    def sortit(tripods):         in range(1, len(tripods)):             tmp = tripods[i][3]             k =             while k > 0 , tmp < tripods[k - 1][3]:                 tripods[k] = tripods[k - 1]                 k -= 1             tripods[k] = tmp 

whenever runs gives me typeerror: int object not suscriptable. tripods list of namedtuples , index 3 of namedtuple want list ordered by.

def sortit(tripods):     in range(1, len(tripods)):         tmp = tripods[i]         k =         while k > 0 , tmp[3] < tripods[k - 1][3]:             tripods[k] = tripods[k - 1]             k -= 1         tripods[k] = tmp 

i have modified code. assigning tripods[i][3] tmp, int. that's why compiler warns int not suscriptable.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -