Assuming this is an array of objects by name...
myarray = new Array( "rock", "me", "thrower");
just calling myarray.sort(); //without any arguments
returns
myarray == ("me","rock","thrower")
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jon
McLennan
Sent: Wednesday, May 30, 2001 4:27 PM
To: [EMAIL PROTECTED]
Subject: [Dynapi-Help] OT: Sorting arrays of objects
I'm trying to sort an array of objects, but my sort function doesn't appear
to be working and I can't find any documentaion on string or object
comparisons.
I'm trying to sort based on the object's name so the call looks like this:
arrToSort.sort( compare )
function compare( a, b ) { return a.name - b.name; }
This doesn't work ( obviously ), and I can't seem to figure it out. Does
anyone out there know how to do this or know of some documentation that can
point me in the right direction?
Jon
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.255 / Virus Database: 128 - Release Date: 5/17/2001
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.255 / Virus Database: 128 - Release Date: 5/17/2001
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help