I have this array:
["fff-44-44", "1232-44-ddd", "aaa-222-333"]
I want to reorder this object:
Object { "fff-44-44": {…}, "aaa-222-333": {…}, "1232-44-ddd": {…} }
to this:
Object { "fff-44-44": {…}, "1232-44-ddd": {…}, "aaa-222-333": {…} }
Tried the following:
var arr = Object.keys(this.state.products).map(function (key) { return this.state.products[key]; }.bind(this))
arr.sort(function(a, b){
return this.props.orderArray.indexOf(a) - this.props.orderArray.indexOf(b);
}.bind(this))
let final = arr.reduce(function(o, val) { o[val] = val; return o; }, {});
It seems that the property of the object isn't converted into indexes, which a huge roadblock and I am not sure what I am doing wrong.