```ruby
# Extend Array with a sort_by_distance method.
class Array
  # This method creates a "distance" attribute on each object, calculates the
  # distance from the passed origin, and finally sorts the array by the
  # resulting distance.
  def sort_by_distance_from(origin, opts={})
    warn "[DEPRECATION] `Array#sort_by_distance_from(origin, opts)` is deprecated. Please use Array#sort_by{|e| e.distance_to(origin, opts)} instead which is not destructive"
    sort_by!{|e| e.distance_to(origin, opts)}
  end
end```

Make code ruby 1.8 compatible
user
```ruby
# Extend Array with a sort_by_distance method.
class Array
  # This method creates a "distance" attribute on each object, calculates the
  # distance from the passed origin, and finally sorts the array by the
  # resulting distance.
  def sort_by_distance_from(origin, opts={})
    warn "[DEPRECATION] `Array#sort_by_distance_from(origin, opts)` is deprecated. Please use Array#sort_by{|e| e.distance_to(origin, opts)} instead which is not destructive"
    self[0..-1] = sort_by{|e| e.distance_to(origin, opts)}
  end
end```
assistant