compat: Add simplified merge sort implementation from glibc