sort_field = 'data'
sort_order ='desc'
arr = [ {data: 'one'}, {data: 'bbb'} ]
aaa = arr
if sort_field
aaa.sort_by! { | v | v[sort_field.to_sym] }
aaa.reverse! if sort_order == 'desc'
end
puts aaa
sort_field = 'data'
sort_order ='desc'
arr = [ {data: 'one'}, {data: 'bbb'} ]
aaa = arr
if sort_field
aaa.sort_by! { | v | v[sort_field.to_sym] }.send(sort_order == 'desc' ? :reverse : :itself)
end
puts aaa