我的问题可能看起来有点傻,但我正在编写一个从给定数据输出 HTML 表格的对象。给定的数据是一个 json 编码的字符串,其中包含这些标头数组和数据对象:
例如:
{
"header":["id","fname","lname","position"],
"data":{
"0":{"position":"Developer","fname":"Tom","lname":"Jones","id":12},
"1":{"position":"UI Designer","fname":"John","lname":"Smith","id":18},
"2":{"position":"UX Specialist","fname":"Farid","lname":"Rn","id":110}
}
}
问题是数据的顺序与标题不同。
我想使用标头数组作为参考,并按它对每一行数据对象进行排序。那可能吗?