Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting Q.
#1
Suppose I have a list of lists:
listA = [['A', 5], ['B', 18], ['C', 18], ['D', 34] 
I know how to use itemgetter to sort by the second element, the number, in reverse order. D 34, C 18, B 18, A 5 etc...

What if I want to make sure that in cases where 2 entries have the same number they are sorted alphabetically?

I want the numbers descending but the letters ascending. D 34, B 18, C 18, A 5 etc...

How do I do that please?
Reply


Messages In This Thread
Sorting Q. - by jarrod0987 - Mar-31-2018, 08:42 PM
RE: Sorting Q. - by Larz60+ - Mar-31-2018, 09:00 PM
RE: Sorting Q. - by jarrod0987 - Mar-31-2018, 09:15 PM
RE: Sorting Q. - by Larz60+ - Mar-31-2018, 09:19 PM
RE: Sorting Q. - by jarrod0987 - Mar-31-2018, 09:32 PM
RE: Sorting Q. - by Larz60+ - Mar-31-2018, 11:34 PM
RE: Sorting Q. - by jarrod0987 - Apr-01-2018, 12:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sorting a copied list is also sorting the original list ? SN_YAZER 3 3,325 Apr-11-2019, 05:10 PM
Last Post: SN_YAZER

Forum Jump:

User Panel Messages

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