I have an array of objects, each with a property called sort_order
that I need to change based on another property score
but the catch is I can't actually change the order of the array which means no Array.sort()
.
Basically I want this:
function compare(a,b){
return b.score - a.score;
}
scores.sort(compare);
but instead of actually sorting I want to set a.sort_order
and b.sort_order
accordingly.
Aucun commentaire:
Enregistrer un commentaire