sorting is done in the calling function as well