Question: Write a function sort _ demand _ supply ( status ) that takes a dictionary of demands and supplies and returns the information as a
Write a function sortdemandsupplystatus that takes a dictionary of demands and supplies and returns the information as a list of tuples sorted by the value so that locations with greatest demands the most negative number are provided first.
Input:
status: a dictionary of demands and supplies. The keys are the location labels strings and the values are integers, where a positive value represents supply and a negative value represents demand.
Your function should return a list of tuples, where each tuple is of the form location demandsupply and the list should be sorted in ascending order by their demandsupply ie greatest demand to greatest supply If two or more locations have the same demand or supply, tiebreak by alphanumeric order on their labels.
You may assume:
Inputs are correctly formatted data structures and types
upply
Another example:
upply
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
