Chaotic sort algorithm - Cpp implementation