Custom Sort by Frequency
Medium
sorting
Apple
Microsoft
Amazon
Sort a list of integers by frequency (most frequent first). If two numbers have the same frequency, sort them in ascending order.
Example
sort_by_frequency([4, 5, 6, 5, 4, 3])
# => [4, 4, 5, 5, 3, 6]
Test Cases
Python Editor
Output
Click "Run" to see results...