Changed it to use threads - now it needs to be join after the sorting in each thread