I want to merge these 2 arrays by ID and sorted the merged result array by ID desc.
Don't want to use any external lib like Lodash or Underscore
Prefere to use ES6 with a less lines of code as possible
.
const array1 = [
{id: "14", text: "Notice 14"},
{id: "13", text: "Notice 13"},
{id: "12", text: "Notice 12"},
{id: "11", text: "Notice 11"},
{id: "10", text: "Notice 10"},
]
const array2 = [
{id: "11", text: "Notice 11a"},
{id: "14", text: "Notice 14a"},
{id: "12", text: "Notice 12"},
{id: "15", text: "Notice 15"},
]
I want a merged array by ID and order by ID desc:
[
{id: "15", text: "Notice 15"}
{id: "14", text: "Notice 14a"}
{id: "13", text: "Notice 13"}
{id: "12", text: "Notice 12"}
{id: "11", text: "Notice 11a"}
{id: "10", text: "Notice 10"}
]