Changed sorting to sort withing a given range.
Removed some comments.