Fixed the sorting problem