added options to sort() and _sort()

Fixes #1004