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
  python calculate float plus float is incorrect? sirocawa 6 240 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,310 Apr-19-2022, 06:50 PM
Last Post: Gribouillis
  list sort() function bring backs None CompleteNewb 6 4,109 Mar-26-2022, 03:34 AM
Last Post: Larz60+
  Tuple generator, and function/class syntax quazirfan 3 3,859 Aug-10-2021, 09:32 AM
Last Post: buran
Exclamation TypeError: '>=' not supported between instances of 'int' and 'str' helpme1 11 8,789 Mar-11-2021, 11:13 AM
Last Post: helpme1
  Combine Two Recursive Functions To Create One Recursive Selection Sort Function Jeremy7 12 7,335 Jan-17-2021, 03:02 AM
Last Post: Jeremy7
  How to use a tuple as an argument of a function zarox 5 3,573 Nov-14-2020, 08:02 PM
Last Post: buran
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,799 Nov-04-2020, 11:26 AM
Last Post: Aggam
  Type error: '>' not supported between instances of 'NoneType' and 'int' spalisetty06 1 10,474 Apr-29-2020, 06:41 AM
Last Post: buran
  TypeError: '<' not supported between instances of 'str' and 'int' Svensation 5 8,794 Jan-20-2020, 08:12 PM
Last Post: buran

Forum Jump:

User Panel Messages

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