Question: Write a function called MaxRevenueSort ( ) that takes the array clled NumItemsSold as an input. MaxRevenueSort ( ) calculates the revenue made, and sorts
Write a function called MaxRevenueSort that takes the array clled NumItemsSold as an input. MaxRevenueSort calculates the revenue made, and sorts the revenue in descending order in an array called sortedRevenue. Descending order in the array mean the highest revenue value is the position in sortedRevenue. The remaining elements descrease in order from left to right on the first row until the last column.
Hint: The internal functions sort and reshape should be used.
Restrictions: Loops should not be used
Ex: Given
numItemsSold ; ; ;
the output is
sortedRevenue
function sortedRevenue MaxRevenueSortnumItemsSold
itemPrice ; ; ;
Calculate Revenue
revenue numItemsSold itemPrice
Sort Revenue in descending order
sortedRevenue reshapesortrevenue: 'descend'
end
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
