replaced the insersion sort by a merge sort reduces compilation time, memory usage and template recursion depth