sort_asc(v), sort_desc(v) and rank(v,s) functions

Continuing pull request #38, which was closed due to the new gitflow.

Now with everything: rev and fwd auto-diff and their unit tests for sort functions.