Autor Zpráva
peta
Profil
seradit pole umim. Ale ted bych potreboval seradit associativni pole, objekt

arr = [5,2,7];
arr.sort(function(a,b){return a-b;});
alert(arr);
-> 2,5,7

A ted bych potreboval ale
obj = {'a':5,'b':2,'c':7};
obj.sort(function(a,b){return a-b;});
alert(obj);
-> {'b':2,'a':5,'c':7}

existuje na to funkce nebo si ji napsat?
peta
Profil
pouzil jsem toto, funguje ve FF, ostatni nezkousel:

var MyProfile = {
'profile':{
123:['jmeno','vek']
},
'contact':{
234:['jmeno1','vek'],
235:['jmeno2','vek']
}
};


function contactSort()
{
var a,b, i,j, o,p;
o = new Object();
p = new Object();
a = 'contact';

for (i in MyProfile[a])
{if (MyProfile[a][i]!=null) {o[i] = MyProfile[a][i][1];}}
for (i in MyProfile[a])
{
for (j in o)
{if (o[j]!=null) {b=j; break;}}
for (j in o)
{if (o[j]<o[b]) {b=j;}}
if (b!=null)
{
p[b] = new Array();
for (j=0;j<MyProfile[a][b].length;j++)
{p[b][j] = MyProfile[a][b][j];}
o[b]=null;
}
}
MyProfile[a] = new Object();
for (i in p)
{
MyProfile[a][i] = new Array();
for (j=0;j<p[i].length;j++)
{MyProfile[a][i][j] = p[i][j];}
}
}
Toto téma je uzamčeno. Odpověď nelze zaslat.

0