I have an array of array of objects which is fetched from API. I want to display it keys of key-value pairs as headings/column names for a table. Currently the headings are coming in any random order.
But I want to display the fields mentioned in orderArray first then the rest of headings.
I have created an array of column names in the order I want
[destination_country_name, destination_country_id , primary_cost]
rest of the data can come in any order
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"
}
]
Table with column names (in the below order only):
destination_country_name |destination_country_id |primary_cost