UPDATE This is the json data retrieved through an API using axios.
bannerData= [
{
"id": 118,
"title": "Geruchsbel\u00e4stigung",
"location": "DOR",
"pressInformation": [
{
"id": 257,
"title": "Chemi257"
},
{
"id": 256,
"title": "Chemi256",
}
]
},
{
"id": 144,
"title": "Testing Stage",
"location": "LEV",
"pressInformation": [
{
"id": 254,
"title": "Chemi254",
},
{
"id": 261,
"title": "Chemi261",
}
]
}
]
computed: {
orderedUsers: function() {
this.secondSubBanner = [];
for (let i = 0; i < this.bannerData.length; i++) {
this.subBanner = this.bannerData[i].pressInformation;
for (let j = 0; j < this.subBanner.length; j++) {
this.secondSubBanner.push(this.subBanner[j].id);
console.log(this.secondSubBanner); // output: 257, 256, 254,261
}
}
return this.secondSubBanner;
},
sortedArray() {
let v = this.orderedUsers.sort();
console.log(v); // output: 254, 256, 257, 261
return _.orderBy(this.bannerData, v)
}
sortedArray prints the id's in order using sort(), but it doesn't properly order the Json properties depending on _.orderBy()
. Can someone point out my mistake?