orderedArray= function(arr,order){
return order.map(function(itm){return arr[itm]});
}
var sequence= [0, 3, 4, 2, 5, 1],arr=["one","two","three","four","five","six"]
arr=new orderedArray(arr,sequence);
/* returned value: (Array)
one,four,five,three,six,two
*/
//You can make the order an unindexed property of the array,
// and call array.ordered()
Array.prototype.ordered= function(order){
var arr= this;
order=order || this.order;
return order.map(function(itm){
return arr[itm];
});
}
var arr= ["one","two","three","four","five","six"],
sequence= [0, 3, 4, 2, 5, 1];
arr.order=sequence;
arr.ordered()
/* returned value: (Array)
one,four,five,three,six,two
*/