quick sort in perl and R