Fork Copy // Defined sort order starting with the 'lowest' table in the SQL schema const importOrder = ["Photo", "Address", "State", "Country"]; const tables = [ { name: "Address", schema: [] }, { name: "State", schema: [] }, { name: "Photo", schema: [] }, { name: "Country", schema: [] } ]; const sortByObject = importOrder .reduce((obj, item, index) => { return { ...obj, [item]: index, }; }, {}); const customSort = tables.sort((a, b) => sortByObject[a.name] - sortByObject[b.name]);