[engine] Sort links in order of REL according to CONFIG.REL_GROUPS