i have this code:
response = Place.all
nearPlaces = []
for el in response
distance = el.distance_to([41.9097306,12.2558141])
if distance < 20
el.distance = distance
nearPlaces.push(el)
end
end
orderPlaces = nearPlaces.sort_by{|e| e[:distance]}
But the array is not sort by distance filed...any suggestion?
nearPlaces.sort_by(&:distance)