Custom implementations of sorting algorithms