Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] [Javascript] Shouldn't there be a sort option on objects
- Date: Sun, 06 Feb 2011 19:19:23 +0900
- From: Dave M G <dave@example.com>
- Subject: [tlug] [Javascript] Shouldn't there be a sort option on objects
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7
TLUG, Just spent the last hour or so going mental trying to apply a sort() on an object. Turns out it only works on arrays. Okay, fine, but then it turns out, as far as I can tell by looking around the net, that there is no sort() on objects, which seems to me a bit of a miss. I thought objects were supposed to be more dynamic and flexible. What I'm actually trying to do is sort a multidimensional object that was created from JSON data. I found a few examples of how to do that with an array and the sort() method. Nice, easy to implement examples. However, sorting the data for an object seems like a nightmare. Or at least, I haven't been able to find an example that I can parse down to my level of understanding. Has anyone encountered this before and found a workable solution? For more specifics, my object looks like this toplevel.midlevel.dataIWantToSortBy "midlevel" is just a number that I use to order the data when I display it. "dataIWantToSortBy" contains... uh... stuff. For now let's just say it contains letters for alphabetical sorting. So What I want to do is turn this: toplevel.1.dataIWantToSortBy.value = C toplevel.2.dataIWantToSortBy.value = A toplevel.3.dataIWantToSortBy.value = B Into: toplevel.1.dataIWantToSortBy.value = A toplevel.2.dataIWantToSortBy.value = B toplevel.3.dataIWantToSortBy.value = C I hope that makes sense. -- Dave M G
- Follow-Ups:
- [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Stephen J. Turnbull
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Fredric Fredricson
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Raymond Wan
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Darren Cook
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Great Git resources -- thanks!
- Next by Date: Re: [tlug] Great Git resources -- thanks!
- Previous by thread: Re: [tlug] Volunteer
- Next by thread: [tlug] [Javascript] Shouldn't there be a sort option on objects
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links