func Dir2Id: sort the id, add safe strategy to avoid ne=(none,none,none) in main func