How to I arrange arrange k element frequency in in decreasing order in ruby?

后端 未结 0 1433
余生分开走
余生分开走 2020-12-01 00:51

array = [1,1,2,2,2,3] should return new_array = [2,2,2,1,1,3]

Heres what I have tried so far

  1. converted array into hash
  2. key being the element and
相关标签:
回答
  • 消灭零回复
提交回复
热议问题