function sortArray(x,y)
{
return ((x[1] < y[1]) ? -1 : ((x[1] > y[1]) ? 1 : 0));
}
var givenarr = [[0,8],[1,9],[2,7]];
givenarr.sort(sortArray);
========================
The result array will be givenarr = [[2,7],[0,8],[1,9]];
function sortArray(x,y)
{
return ((x[1] < y[1]) ? -1 : ((x[1] > y[1]) ? 1 : 0));
}
var givenarr = [[0,8],[1,9],[2,7]];
givenarr.sort(sortArray);
========================
The result array will be givenarr = [[2,7],[0,8],[1,9]];