Fixed check in sort routine when specifying limits.

The check for start/end was incorrect. Also, added new unit test
test_sort.py
Merge pull request #39 from tpena/feature/sort

Fixed check in sort routine when specifying limits.