initial code of sorting