post sort algorithm