Start from two sorted runs of length 1, merge into a single run of twice the length. Repeat until a single sorted run is left. Mergesort needs N/2 extra buffer. Performance is second place on average, with quite good speed on nearly sorted array. Mergesort is stable in that two elements that are equally ranked in the array will not have their relative positions flipped.
#include <stdlib.h>
#include <stdio.h>
#define uint32 unsigned int
#include <stdlib.h>
#include <stdio.h>
#define uint32 unsigned int