您可以将函数
sort与函数一起使用
indexOf。
var array = [ { ID: 168, NAME: "First name", CODE: "AD" }, { ID: 167, NAME: "Second name", CODE: "CC" }, { ID: 169, NAME: "Third name", CODE: "CCM" }, { ID: 170, NAME: "Fourth name", CODE: "CR" }], item_order = ["CCM","CR","AD","CC"];array.sort((a, b) => item_order.indexOf(a.CODE) - item_order.indexOf(b.CODE));console.log(array);.as-console-wrapper { max-height: 100% !important; top: 0; }


