2. Product Sort
In a warehouse, a manager would like to sort
the items in the stock. Given an array of n
item values, sort the array in ascending
order, first by the number of items with a
certain value, then by the values themselves.
Example
n = 6
items = [4, 5, 6, 5, 4, 3]
• There are 2 values that occur twice: [4, 4, 5,
57.
. There are 2 values that occur once: (3, 6).
• The array of items sorted by quantity and
then by value in ascending order is [3, 6, 4,
4, 5, 57
Function Description
Answers
Answered by
1
Answer:
sorry
Explanation:
I don't know answer
Answered by
0
Answer:
lst1 = [4, 5, 6, 5, 4, 3]
dicti = {}
for i in lst1:
a = lst1.count(i)
if a not in dicti.keys():
dicti[a] = [i]
else:
dicti[a].append(i)
key = list(dicti.keys())
key.sort()
out =[]
for i in key:
dicti[i].sort()
for i in dicti[i]:
out.append(i)
print(out)
Explanation:
No Explanation
Similar questions