Added sort functions; extended docstrings.