La opción mas votada esta muy buena, puedes ordenar por cualquier atributo y en cualquier orden.
Les dejo el link a esta respuesta:
http://stackoverflow.com/a/4698083
function sortJsonArrayByProperty(objArray, prop, direction){
if (arguments.length<2) throw new Error("sortJsonArrayByProp requires 2 arguments");
var direct = arguments.length>2 ? arguments[2] : 1; //Default to ascending
if (objArray && objArray.constructor===Array){
var propPath = (prop.constructor===Array) ? prop : prop.split(".");
objArray.sort(function(a,b){
for (var p in propPath){
if (a[propPath[p]] && b[propPath[p]]){
a = a[propPath[p]];
b = b[propPath[p]];
}
}
// convert numeric strings to integers
a = a.match(/^\d+$/) ? +a : a;
b = b.match(/^\d+$/) ? +b : b;
return ( (a < b) ? -1*direct : ((a > b) ? 1*direct : 0) );
});
}
}
sortJsonArrayByProperty(results, 'attributes.OBJECTID');
sortJsonArrayByProperty(results, 'attributes.OBJECTID', -1);
En las ultimas 2 lineas se manda llamar la funcion de orden ascendente y descendente, ordenandolo por el OBJECTIDTeniendo el JSON de ejemplo:
{"results": [
{
"layerId": 5,
"layerName": "Pharmaceutical Entities",
"attributes": {
"OBJECTID": "35",
"FACILITYTYPE": "Pharmacy",
"FACILITYSUBTYPE": "24 Hr Pharmacy",
"COMMERCIALNAME_E": "SADD MAARAB PHARMACY",
},
"geometryType": "esriGeometryPoint",
},
{
"layerId": 5,
"layerName": "Pharmaceutical Entities",
"attributes": {
"OBJECTID": "1",
"FACILITYTYPE": "Pharmacy",
"FACILITYSUBTYPE": "24 Hr Pharmacy",
"COMMERCIALNAME_E": "GAYATHY HOSPITAL PHARMACY",
},
"geometryType": "esriGeometryPoint",
},
{
"layerId": 5,
"layerName": "Pharmaceutical Entities",
"attributes": {
"OBJECTID": "255",
"FACILITYTYPE": "Pharmacy",
"FACILITYSUBTYPE": "24 Hr Pharmacy",
"COMMERCIALNAME_E": "AL DEWAN PHARMACY",
},
"geometryType": "esriGeometryPoint",
}
]}