Python Forum
Writing a lambda function that sorts dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Writing a lambda function that sorts dictionary
#1
Hi guys! :)

dict1 = {'c':3, 'a':5, 'f':7, 'e':4}
Was wandering how to sort this dictionary by highest value first using lambda function?

expected result:
dict2 = {'f':7, 'a':5, 'e':4, 'c':3}
Appreciate the help !
Reply


Messages In This Thread
Writing a lambda function that sorts dictionary - by GJG - Mar-09-2021, 06:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Function parameter not writing to variable Karp 5 1,016 Aug-07-2023, 05:58 PM
Last Post: Karp
  Add two resultant fields from python lambda function klllmmm 4 954 Jun-06-2023, 05:11 PM
Last Post: rajeshgk
  passing dictionary to the function mark588 2 1,025 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  Create a function for writing to SQL data to csv mg24 4 1,224 Oct-01-2022, 04:30 AM
Last Post: mg24
  Writing into 2 text files from the same function paul18fr 4 1,722 Jul-28-2022, 04:34 AM
Last Post: ndc85430
  I am writing a car rental program on python. In this function I am trying to modify aboo 2 2,805 Aug-05-2021, 06:00 PM
Last Post: deanhystad
  2 Different Sorts in a Dataframe stylingpat 1 1,942 Apr-14-2021, 03:02 PM
Last Post: stylingpat
  Using Dictionary to Test Evenness of Distribution Generated by Randint Function new_coder_231013 6 3,344 Feb-23-2021, 01:29 PM
Last Post: new_coder_231013
  Writing a function to calculate time range in Unix Epoch Time t4keheart 2 3,056 Jul-15-2020, 01:55 AM
Last Post: t4keheart
  translating lambda in function fabs 1 2,187 Apr-28-2020, 05:18 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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