Move sort function to file parser