Sort JSON array in javascript
5:45 PM
I've write a function for this :
function sortJson(arr, prop, dir) {
return arr.sort(function(a,b) {
var propA = a[prop],propB = b[prop];
if (dir=='asc') {
return propA - propB;
} else {
return propB - propA;
}
});
}
0 comments