merge main logic sortAsc/-desc to one method