Implement sorting algorithms