Implementation of sorting algorithms