Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with Sort
#2
Can you also post the sample file you're reading the data from?

In the meantime, I think this code can help you figure this out:
#Original data
data =((1,19),(2,10),(3,4),(2,7))
#Built-in sort function
print (sorted(data))
#define new sort criteria
print(sorted(data,key = lambda e: e[1]))
Reply


Messages In This Thread
Trouble with Sort - by Milfredo - Sep-13-2020, 10:14 AM
RE: Trouble with Sort - by Askic - Sep-13-2020, 10:51 AM
RE: Trouble with Sort - by Milfredo - Sep-13-2020, 06:50 PM
RE: Trouble with Sort - by scidam - Sep-14-2020, 12:44 AM
RE: Trouble with Sort - by Milfredo - Sep-14-2020, 04:12 AM
RE: Trouble with Sort - by Askic - Sep-14-2020, 05:50 AM
RE: Trouble with Sort - by Milfredo - Sep-14-2020, 06:56 AM
RE: Trouble with Sort - by Askic - Sep-14-2020, 02:21 PM
RE: Trouble with Sort - by Milfredo - Sep-14-2020, 02:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,324 Apr-19-2022, 06:50 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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