[mapguide-users] RE: How to sort a selection set

Jackie Ng jumpinjackie at gmail.com
Tue Jan 31 09:21:16 EST 2012


The sorting function need not be that complicated.

Something like this will suffice:

results.sort(function(objA, objB) {
   if (objA.SORT_PROPERTY < objB.SORT_PROPERTY) {
       return -1; //Less than
   } else if (objA.SORT_PROPERTY > objB.SORT_PROPERTY) {
       return 1; //Greater than
   } else {
       return 0; //Equal
   }
});

Where SORT_PROPERTY is the name of the property of the object you want to
sort on.

- Jackie

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-sort-a-selection-set-tp4344383p4353253.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list