Jackie,
Hey, thanks, I think I am making progress. I am imagining that
SORT_PROPERTY is supposed to be the field name of the passed data, but
that does not work. Can you clarify what I am supposed to use here, and
if it is the field name how I can get determine what it is?
From: Jackie Ng
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
} el
Hmm, hadn't thought about it in that light. But it seems you are
correct, I am sorting an array of JSON objects
Alright so I tried my hand at this, and to be honest it is a little over
my head. I found a JavaScript function that I could use to sort the
values in the Array. It looks like this
But what you are sort()'ing is an array of JSON objects right? That's why you
must pass a sorting function as a parameter to sort() because otherwise
sort() has no clue how the objects are to be sorted.
If it's an array of string literals, then sort() should do the alphabetic
sort
- Jackie
--
Vi
Thanks Jackie,
But according to the information you provided I should be able to simply
use the sort() method since I "just" want to alphabetically sort a
string key field. Thus I am wondering what is missing since that
doesn't work. Perhaps the array returned by MapGuide is not some
ordinary
A javascript Array.sort() on an array of objects generally requires a
comparer function be passed in that determines how one object is greater or
less than another.
http://www.javascriptkit.com/javatutors/arraysort.shtml
- Jackie
--
View this message in context:
http://osgeo-org.1560.n6.nabble.