Javascript - Multidimensional Array Sorting - String And Int - Order By Int
===

After dragging divs in my javascript application... I want to assign a numeric class to all divs, ordered by the position. I've researched a lot, and builded the next... but it just does not work. (Inner HTML does not change)

    var ele=document.getElementsByTagName("div");
    var i=0;
    var MyDrags=new Array();
    while(ele[i]){
     if(ele[i].id.substr(0, 4)=="drag"){
     MyDrags["distance"]=parseInt(document.getElementById(ele[i].id).style.top,10);
     MyDrags["id"]=ele[i].id;
     }
     i++;
    }
    MyDrags.sort(function(a,b) {
    return a.distance - b.distance;
    });
    i=0;
    while(MyDrags["distance"][i]){
     document.getElementById(MyDrags["id"][i]).innerHTML=MyDrags["distance"][i];
     i++;
    }