I'm doing a game that demands a table of positions, which is made up of the names of users entered and their respective final scores. I have doubts about how I could sort such data without getting messed up, since ordering the numerical part is easy, the problem for me would be the names that agree with that numerical ordering. For now I have the function done like this, there is no code of order since I have looked at ways to order, but all would separate the names of the scores and that is not what I am looking for.
The add feature called at the end of the game. Thank you in advance!
function agregar(){
persona=document.getElementById('nombre').value;// recibe el nombre ingresado desde otra funcion
if(persona==""){
contj=contj+1;
auxiliarPersona="Jugador "+contj;
auxiliarPuntaje=contG;
}
else{
auxiliarPuntaje=contG;
auxiliarPersona=persona;
}
tabla.push(auxiliarPersona,auxiliarPuntaje);
document.getElementById("tab").innerHTML=tabla;
}