Python Forum
Sort Function: <' not supported between instances of 'float' and 'tuple'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sort Function: <' not supported between instances of 'float' and 'tuple'
#1
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
Reply
#2
  • Fix indentation
  • Show complete unaltered error traceback (wrapped with bbcode error tags)
  • Show contents of nextlist (after line 1 has executed)
Reply
#3
(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!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation TypeError: '>=' not supported between instances of 'int' and 'str' helpme1 11 1,683 Mar-11-2021, 11:13 AM
Last Post: helpme1
  Combine Two Recursive Functions To Create One┬áRecursive Selection Sort Function Jeremy7 12 1,416 Jan-17-2021, 03:02 AM
Last Post: Jeremy7
  How to use a tuple as an argument of a function zarox 5 755 Nov-14-2020, 08:02 PM
Last Post: buran
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 745 Nov-04-2020, 11:26 AM
Last Post: Aggam
  Type error: '>' not supported between instances of 'NoneType' and 'int' spalisetty06 1 2,886 Apr-29-2020, 06:41 AM
Last Post: buran
  TypeError: '<' not supported between instances of 'str' and 'int' Svensation 5 3,077 Jan-20-2020, 08:12 PM
Last Post: buran
  TypeError: Not supported between instances of 'function' and 'int' palladium 9 8,300 Dec-06-2019, 12:40 AM
Last Post: palladium
  TypeError: '>=' not supported between instances of 'str' and 'int' AsadZ 8 3,945 Aug-20-2019, 11:45 AM
Last Post: ThomasL
  Comaparing Float Values of Dictionary Against A Float Value & Pick Matching Key firebird 2 1,217 Jul-25-2019, 11:32 PM
Last Post: scidam
  Call a Function contained in a Tuple SamGer 7 1,890 Jun-14-2019, 05:00 PM
Last Post: ThomasL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020