So, there will probably be guys that will say this is a duplicate, but I read many relatively similar questions and still I'm unable to find an answer that resolves this particular problem, I've even tried some npm modules that claim to solve this, but to no avail...
Well, I have an array of objects:
var objArr = [{ '5': 1,'6': 1,'34': 3,id: 1,question: '12',author: 'Zoran Stanić' }];
and another array which should help in sorting the first array:
var sortingArr = [ 'id', 'question', 'author', '34', '5', '6' ];
The result should be this:
[{id: 1, question: '12', author: 'Zoran Stanić', '34': 3, '5': 1, '6': 1}]
How can I achieve this?
P.S. These are the values from the database, and the order of objArr could be completely different than the one in example, depending on the db logic - it's MySQL thingy.