SamirI think what they mean "dynamic layers" as a property of the service. NOTE: this is a property of the ArcGIS REST Services Directory for your MapServiceSupports Dynamic Layers: trueI am not too sure if this is the correct way for you to follow. I just tried implementing what you are trying to do and had no success. However, in my case, the queries ran correctly with no errors but the featureSet was not "ordered by" the field that I indicated. Sometimes it would actually change my result set based on OBJECTID ASC or DESC order (which I had indicted in the orderByFields param) but it NEVER sorted by the field that I indicated. I am not sure if I was implementing it correctly ... but my results were inconclusive. I tried it with both a featureLayer.selectFeatures and an MapService URL via a QueryTask.execute. No luck. Sorry, I wish I could be more of help but I am also stuck here with no way to order my results other than what was suggested by Steve (array.sort).Below is a "watered-down" version of the two different sets of code that I used for testing:
//TEST 1: Use existing featureLayer to perform query
var selectQuery = new esri.tasks.Query();
selectQuery.geometry = geometry;
selectQuery.orderByFields = ["MEASURE ASC"];
pointFeatureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
//TEST 2: Use QueryTask to query MapServer Layer
var queryTaskOperation = new esri.tasks.QueryTask("http://myserver:6080/arcgis/rest/services/FeatureServices/TestEditngService/MapServer/0");
query.outFields = ["OBJECTID", "REACHCODE", "REACHRESOLUTION", "MEASURE", "EVENTTYPE"];
var query= new esri.tasks.Query();
query.geometry = geometry;
query.orderByFields = ["MEASURE DESC"];
query.returnGeometry = true;
queryTaskOperation.execute(query, function (featureSet) {
alert("total features = " + featureSet.features.length);
//NOTE: I step through the code and can see what the returned featureSet.features array looks like here!
}, function (e) {
alert("Error during query task");
});