Add more comments in the sorting code