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]



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


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links