How to sort by array by num property in this JavaScript code -


how sort array num property in javascript array.

var data = [{     005: { `num`: 1360487},     047: { `num`: 2519472},     061: { `num`: 1559115},     081: { `num`: 2232710},     085: { `num`: 54956 }   }]; 

enter image description here

what manipulating array containing 1 object, not array of objects. should change structure of data make easier manipulate, example be:

var data = [      [005, { num: 1360487}],      [047, { num: 2519472}],      [061, { num: 1559115}],      [081, { num: 2232710}],      [085, { num: 54956 }],  ];    data.sort(      function (firstelem, secondelem) {          return firstelem[1].num - secondelem[1].num;    }  );    // data sorted


Comments