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



Hi Dave,

On Mon, Feb 7, 2011 at 10:50 PM, Dave M G <dave@example.com> wrote:
> Stephen, Josh, Fredric, Raymond,
,,,
> If I can get JSON to look at this as an array, not an object, I think I
> can do something like this:
...
>
> Can anyone break it down to me on my lower-than-noob level?


As I said, I haven't written any Javascript before and know nothing
about JSON -- first time hearing about it.

But it sounds like you could convert JSON data into an object via a
parser [1].  I don't know where to get one, but it sounds like there
is one in Javascript already [2].  And then you can sort it using
examples here [3].

Given what you have isn't a text file, perhaps you can skip to the
sorting?  From reading these pages, it sounds like objects in this
sense aren't lined up in an array as what I'm use to in some
languages.  Seems like they are calling an array an object...which
sort of explains what you meant in your first post...  In C++, array
(vector) can hold objects but the array itself has methods like
foo.size () which returns the number of objects stored in the array.
I suppose what Javascript is doing with the JSON data is something
similar?  That is, the array is an object where you can call sort
function on...  Just a guess...

Also sounds like JSON is a data format and you're not required to use
Javascript...

Hope this helps a bit...

Ray

[1] http://en.wikipedia.org/wiki/JSON (End of "Data types, syntax and example")
[2] http://www.json.org/js.html
[3] http://stackoverflow.com/questions/979256/how-to-sort-a-json-array


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links