IMHO it doesn't fit at all with the other things. You can implement In-Place Mergesort or one of its variants by studying Wikipedia. Or you can just look up a nice implementation from the OPs site and port it to your favorite language. That said, this argmin/argmax thing does absolutely not fit.