The problem is the fact that what PHP calls "array" can be, but can also not be an array in JavaScript. You are getting an object (or associative array, or dictionary, or hashtable):
{"96":{"product":"Drone","quant":"23","available":"true"},
"43":{"product":"Aereo","quant":"2","available":"false"},
"55":{"product":"Geos","quant":"45","available":"true"}...}
which is not orderable in JavaScript. You have three options: convert to a true array (if you don't care about keys, or if you can insert the keys into the objects), use an index array (and sort that instead), or (in ES6) use Map
and its contract that it shall preserve the order of items in order of insertion (but it only works on new JavaScript environments).
For example, one way would be this (using an index array):
var data = {"96":{"product":"Drone","quant":"23","available":"true"},
"43":{"product":"Aereo","quant":"2","available":"false"},
"55":{"product":"Geos","quant":"45","available":"true"}};
var keys = Object.keys(data);
keys.sort(function(a, b) {
var pa = data[a].product;
var pb = data[b].product;
if (pa === pb) return 0;
return (pa < pb) ? -1 : 1;
});
keys.forEach(function(key) {
console.log(key, data[key]);
});
<!-- results pane console output; see http://meta.stackexchange.com/a/242491 -->
<script src="http://gh-canon.github.io/stack-snippet-console/console.min.js"></script>