I've got a distance attribute in my User model :

```
attr_accessor :distance

```

So when I calculate the distance for each user, and store it in the distance then I can sort them like :

```
users.sort_by!(&:distance)

```

And the users get sorted according to the distance appropriately. But when I include other associated methods i.e :

```
users.includes(:photo).sort_by!(&:distance)

```

This doesn't sort the users at all, why is this? How can I sort it with distance but include association as well?