Added retrieval of entities sorted by distance