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]Re: [tlug] [Javascript] Shouldn't there be a sort option on objects [SOLVED]
- Date: Tue, 08 Feb 2011 22:52:36 +0900
- From: Dave M G <dave@example.com>
- Subject: Re: [tlug] [Javascript] Shouldn't there be a sort option on objects [SOLVED]
- References: <4D4E75AB.5060703@example.com> <87aai91c4o.fsf@example.com> <4D4F65F2.1060000@example.com> <87sjw0z3g8.fsf@example.com> <4D4FF8AB.3090809@example.com> <4D50BBF5.8020506@example.com>
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7
TLUG, Got the answer by asking on Stack Overflow: http://stackoverflow.com/questions/4929924/how-to-sort-a-javascript-object-or-convert-it-to-an-array Basically, downloaded a library called "underscore", which contained a function that forms the right kind of array from an object: var sortedObject = _.sortBy(object, function(val, key, object) { // return an number to index it by. then it is sorted from smallest to largest number return val; }); Having a little trouble with some variables being over written when I don't intend... but I think that's an entirely separate problem. The focus of this thread, sorting an associative array in Javascript, has been solved. Thanks to everyone for their explanations and advice. -- Dave M G
- References:
- [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Dave M G
- [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: Dave M G
- Re: [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: Dave M G
- Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- From: Dave M G
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Are ordered hashes useful?
- Next by Date: Re: [tlug] Are ordered hashes useful?
- Previous by thread: Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- Next by thread: Re: [tlug] [Javascript] Shouldn't there be a sort option on objects
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links