假设我们有这样的数组:
const words = ['luigi', 'Bar', 'Test', 'zac1', 'Alf0'];
现在我想按字母顺序对这个数组进行排序:
words.sort((a, b) => a.localeCompare(b));
想象一下,我们有一系列超级单词.这些单词具有很高的优先级,应该在"单词列表"的顶部.
const superWords = ["zac1", "Test"]
因此,单词数组的预期结果将是:
const desiredResult = ["Test", "zac1","Alf0", "Bar", "luigi"]
我该怎么做?