Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting a dictionary
#3
The easiest to understand is to create a list, in the order you want to sort. Oops, the following list is in reverse order.

list_to_sort=[('key1', 0.061, 0),
('key2', 0.034, 0),
('key3', 0.046, 0),
('key4', 0.0593, 0),
('key5', 0.091), 0],
('key1', 0.025, 1),
('key2', 0.046, 1),
('key3', 0.014, 0),
('key4', 0.054, 1),
('key5', 0.05, 1)]
Reply


Messages In This Thread
Sorting a dictionary - by v_mn - Sep-12-2022, 05:08 PM
RE: Sorting a dictionary - by deanhystad - Sep-12-2022, 06:43 PM
RE: Sorting a dictionary - by woooee - Sep-12-2022, 06:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sorting a copied list is also sorting the original list ? SN_YAZER 3 5,768 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