There is an array whose elements are same items in random order. I want to reorder the array such that items with high frequencies appear first and then the items with the lowest frequencies appear last.
Basically, what would be the code to return the result below?
const a = [1,5,3,3,2,3,4,3,3,2,4,4,4];
const result = [3,3,3,3,3,4,4,4,4,2,2,1,5];
Thanks a lot in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…