How can I sort this in javascript...? so, it should 1st campare the 1st element and sort accordingly and if it finds the both elements are same it should consider 2rd