I am making an chat App, all Contacts are saved as Objects in one array:
var contacts = [{name: "Ruud", age: 20},{name: "Elke", age: 17}];
Than I am having the chat messages for every contact saved in an Object Array:
var message_ruud = [{mes: "Hi", date: 1477064075},{mes: "Ok", date: 1477066075}];
var message_elke = [{mes: "Lol", date: 1477069075},{mes: "Ok", date: 1477063075}];
Now the contacts shell be displayed, sorted by the contact with the highest (so the newest time) timestamp. How to do this (so fast as possible)?
EDIT (because question is not clear):
Finally I want to have an Output of the CONTACTS they shell be sortet to where the newest message was sent, to find out where the newest message is you have the message arrays (like _ruud, _elke).
var contacts = [{name: "Ruud"},{name: "Elke"}];
var message_elke = [{msg: "Hi",date: 20}];
var message_ruud = [{msg: "Hello",date: 10}];
document.getElementById("contacts").innerHTML = contacts[0].name+"</br>"+contacts[1].name;
<div id="contacts"></div>