Flatten qsort function with new append3 function