Python Forum

Full Version: Sort Function: <' not supported between instances of 'float' and 'tuple'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello I have this list:

Output:
[((7.2, <__main__.bit object at 0x7f341d8b8700>), <__main__.port object at 0x7f344082cd00>), ((5.5, <__main__.bit object at 0x7f341d8b8790>), <__main__.port object at 0x7f34407aa190>)]
ANd I want to sort it with this code:

nextlist=[(next(ip),ip) for ip in ports]
        while len(nextlist)>0:
            nextlist.sort() 
But I have this error:

nextlist.sort()

TypeError: '<' not supported between instances of 'float' and 'tuple'

HOw to solve it
  • Fix indentation
  • Show complete unaltered error traceback (wrapped with bbcode error tags)
  • Show contents of nextlist (after line 1 has executed)
(Apr-30-2021, 12:41 PM)Larz60+ Wrote: [ -> ]
  • Fix indentation
  • Show complete unaltered error traceback (wrapped with bbcode error tags)
  • Show contents of nextlist (after line 1 has executed)

it is already working now. Just the data was coming differently from the other function. I corrected the other function so now this structure is working. Btw, I already showed the contents of nextlist at the top!!