On Mon, 19 Jul 2010, MartinWittemann wrote:

> Hey Jeff,
> id you want to have a associative array, use a plain JavaScript object.
>
> var myhash = {};
>
> // insert
> myhash["key"] = "value";
> myhash[object] = secondObject;  // object will converted to a string in this
> case!
>
> // delete
> delete myhash["key"];
>
> // exist
> myhash["key"] != undefined
>
> The problem comes in with sorting. JavaScript objects do not have an order
> because they are sets of data. So sorting is not supported by objects.
> And you still have to create the objects on the second level by hand if you
> need them.
>
> myhash["key"] = {};
> myhash["key"]["second"] = 123;
>
> But thats the way JS works.

I think this is rather similar to how it works in Perl ... although it's
probably syntactically more elegant to get the hashes 'sorted' (well, their keys
that is) in Perl. But I might very well be biased ...

I just Googled for

        javascript sort associate array

and found

        http://www.javascriptjedi.com/arraySort/sort_assoc.htm

I didn't really verify it, though ...

Cheers,
Fritz

-- 
Oetiker+Partner AG              tel: +41 62 775 9903 (direct)
Fritz Zaucker                        +41 62 775 9900 (switch board)
Aarweg 15                            +41 79 675 0630 (mobile)
CH-4600 Olten                   fax: +41 62 775 9905
Schweiz                         web: www.oetiker.ch

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to