Допустим, ваш массив
arr=[
{"name"=>"Richard", "email"=>"r@gmail.com", "age" => "32"},
{"name"=>"Bob", "email"=>"bob32@gmail.com", "age" => "52"},
{"name"=>"Bob", "email"=>"bob32@gmail.com", "age" => "21"},
{"name"=>"Bob", "email"=>"bob32@gmail.com", "age" => "58"},
{"name"=>"Bob", "email"=>"bob32@gmail.com", "age" => "45"},
{"name"=>"Bob", "email"=>"bob32@gmail.com", "age" => "67"},
{"name"=>"Bob", "email"=>"bob32@gmail.com", "age" => "92"}
]
Код
p arr.sort_by{|h|h['age']}.first(5)
#=>[{"name"=>"Bob", "email"=>"bob32@gmail.com", "age"=>"21"}, {"name"=>"Richard", "email"=>"r@gmail.com", "age"=>"32"}, {"name"=>"Bob", "email"=>"bob32@gmail.com", "age"=>"45"}, {"name"=>"Bob", "email"=>"bob32@gmail.com", "age"=>"52"}, {"name"=>"Bob", "email"=>"bob32@gmail.com", "age"=>"58"}]