bug fixes to sortbyid in Configure_mapping.R