var obj = {
uniquestring1:
{
obj1: 'content',
obj2: 'content'
},
uniquestring2:
{
obj1: 'content'
}
}
所以我需要由第一父元素包含的元件的編號的對象進行排序。 .sort函數的使用對我來說不是一種解決方案,因爲我需要維護索引assosiaction哪個數組不保留。
結果應該是:
var obj = {
uniquestring2:
{
obj1: 'content'
},
uniquestring1:
{
obj1: 'content',
obj2: 'content'
}
}
你不能一個對象的屬性,因爲他們不是一個有序數組排序。也許你想以某種順序遍歷這些屬性? – js1568
實現了一些排序算法,如果它不適合你的情況,請不要使用jquery .sort。 http://stackoverflow.com/questions/220044/which-sort-algorithm-works-best-on-mostly-sorted-data –