fixed bug.

- zero divide
- destroyed distances key by sort.