In Javascript I need to order objects in an array according to type. Each type has a higher priority, so an object with the type "wipe" should have the highest priority therefore be at the front of the array(index=0).

What would be the best way to sort these objects? Is there a builtin function that can do this?

For eg:

function sortObjects( objs )
{
   // objs is an unsorted array of objects 
   var animPriority = {"wipe": 1, "fly": 2, "iris": 3, "flip": 4, "cube": 5, "blur": 6, "zoom": 7, "fade": 8, "glow": 9, "rotate": 10};

   for (var i=0; i<objs.length; i++)
       if (objs[i].type == "wipe")
          // bubblesort/bubbleswap element in objs[0] with objs[i]????
          // a bubble sort doesn't seem efficient though?
}
Edit
Report