Trouble in Array sort?

your array contains strings, and when you sort strings, the output will be ["108", "94", "95", "96"] but when you convert array elements into integers and sort after that, you must get [94,95,96,108]

Here's how you could do it:

params[:community].keys.sort_by{|k| k.to_i}