added documentation and tests for sortSections()