I was answering a post on codereview.stackexchange.com which led me to explore the performance penalty of using Array<Int> (Java Integer[]) instead of IntArray (Java int[]).
IntArray is expected to have better performance because it avoids the indirection of boxing/unboxing. But for code reuse purposes, Array<Int> is preferable since the algorithm can then be coded once for Array<T: Comparable<T>> and used with any comparable type.
I benchmarked the two approaches and along the way I also compared them to a multi-threaded merge-sort algorithm and merge-sort written in Java. For the multi-threaded version I used Kotlin coroutines.
It is frustrating to code the merge-sort algorithm for IntArray and Array separately since they are identical, except for t