implementation of various sorting algorithms and subproblems