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]];

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.