supersize
supersize

Reputation: 14833

which sort or list makes sense for following data structure

I need some help with this because it is the first time I will have much content in a non-CMS Website which needs to be sorted, setted up and appended to various divs.

I have around 250 people with each Forname, Surname, Telephone number, E-Mail adress, and some infostring.

I thought about doing this with an array like

var peopleArr = ["John, Doe, 0123456789, [email protected], infoshere",
               "Ellen, Page, 0987654321, [email protected], anotherinfo",
               "Megan, Fox, 0249235331, [email protected], niceinfo",
               "and so on"]

but I really don't know if this make sense, since I have to sort all array elements by surname and after that I need to put each element in an own div one the site.

Would you say this makes sense or would you suggest something different? To mention is, that I don't have any experience with XML or JSON, but I am open for it if it makes the most sense.

Thanks in advance.

Upvotes: 0

Views: 46

Answers (1)

Nicolae Olariu
Nicolae Olariu

Reputation: 2555

You could try something like this (as also Bartdude suggested):

var peopleArr = [
                    { forname: 'John', surname: 'Doe', phone: '0123456789', email: '[email protected]', info: 'infoshere' },
                    { forname: 'Ellen', surname: 'Page', phone: '0987654321', email: '[email protected]', info: 'anotherinfo' },
                    { forname: 'Megan', surname: 'Fox', phone: '0249235331', email: '[email protected]', info: 'and so on' }
                ];

Upvotes: 1

Related Questions