6
@cases => [{"name"=>"25 Cases per 60 day", "count"=>0},
{"name"=>"30 Cases for 60 days", "count"=>8},
{"name"=>"10 Cases per 60 days", "count"=>5}]
如果我有一個包含以前結果的對象,我該如何按照DESC順序排序count
? 要獲得實例變量cases
我做使用基於特定鍵的散列元素對數組進行排序
ClassName.all.collect{|e| {'name' => e.name, 'count' => e.contracts.count}}
參考http://stackoverflow.com/questions/3154111/how-do-i-sort-an-array-of-hashes-by-a-value-in-the-hash – rlecaro2