first steps of sorting