Add sort building function to determine the order of reading dat file.