Skip to content

commit-live-students/017-sort-dict-by-value

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Write a Python script to sort (ascending and descending) a dictionary by value.

Notes:

  • Use operator module in python.
  • Define two different functions
    • One to get ascending order of dict
    • Two to get descending order of dict.

Instructions:

  • Program should be written in file build.py

  • Function names should be solution_asc and solution_desc for ascending and descending sorts respectively.

  • Input

     Type:  Dictionary
     Value: {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
    
  • Expected Output

      Type:  List
      Value: In ascending order it should be:  [(0, 0), (1, 2), (2, 1), (3, 4), (4, 3)]
             In descending order it should be: [(4, 3), (3, 4), (2, 1), (1, 2), (0, 0)] 
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages