在表中以标题名称的特定顺序显示对象的数组

RB1*_*B19 5 javascript arrays object reactjs

我有一个从API获取的对象数组数组。我想将键值对的键显示为表的标题/列名称。当前,标题以任何随机顺序出现。

但我想先显示orderArray中提到的字段,然后再显示其余标题。

我已经按照想要的顺序创建了一个列名数组

[destination_country_name, destination_country_id , primary_cost]

其余数据可以按任何顺序排列

var x = [
    {
        "destination_country_id":null,
        "primary_cost":"9.50",
        "region_id":null,
        "destination_country_name":"Everywhere Else",
        "name" : "xyz",
        "place":"abc"
    },
    {
        "destination_country_id":105,
        "primary_cost":"8.00",
        "region_id":null,
        "destination_country_name":"United Kingdom",
        "name" : "xyz1",
        "place":"abc1"
    },
    {
        "destination_country_id":209,
        "primary_cost":"9.50",
        "region_id":null,
        "destination_country_name":"United States",
        "name" : "xyz2",
        "place":"abc2"
    },
    {
        "destination_country_id":123,
        "primary_cost":"5.00",
        "region_id":null,
        "destination_country_name":"Ireland",
        "name" : "xyz3",
        "place":"abc3"
    }
]
Run Code Online (Sandbox Code Playgroud)

具有列名的表(仅按以下顺序):

destination_country_name |destination_country_id |primary_cost