Sorting and linking the list work properly