哪种排序或列表对后续数据结构有意义

时间:2014-04-10 09:46:34

标签: jquery html arrays sorting structure

我需要一些帮助,因为这是我第一次在非CMS网站上有很多内容需要对各种div进行排序,设置和附加。

每个Forname,Surname,电话号码,电子邮件地址和一些信息字符串都有大约250个人。

我想过用

这样的数组做这件事
var peopleArr = ["John, Doe, 0123456789, johndoe@gmail.com, infoshere",
               "Ellen, Page, 0987654321, ellenpage@gmail.com, anotherinfo",
               "Megan, Fox, 0249235331, meganfox@gmail.com, niceinfo",
               "and so on"]

但是我真的不知道这是否有意义,因为我必须按姓氏对所有数组元素进行排序,之后我需要将每个元素放在一个自己的div中作为网站。

你会说这是有道理的还是你会提出不同的建议?值得一提的是,我对XML或JSON没有任何经验,但如果它最有意义,我会对它持开放态度。

提前致谢。

1 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情(也建议Bartdude):

var peopleArr = [
                    { forname: 'John', surname: 'Doe', phone: '0123456789', email: 'johndoe@gmail.com', info: 'infoshere' },
                    { forname: 'Ellen', surname: 'Page', phone: '0987654321', email: 'ellenpage@gmail.com', info: 'anotherinfo' },
                    { forname: 'Megan', surname: 'Fox', phone: '0249235331', email: 'meganfox@gmail.com', info: 'and so on' }
                ];