Sort two dimensional array
<html>
<head>
<title>Array literal</title>
<script type="text/javascript" >
function compare(a, b)
{
return a[1] - b[1];
}
var planets = [
['A', 0.3],
['B', 0.9],
['C', 1],
['D', 0.8],
['E', 2.4]
];
planets.sort(compare);
document.write(planets);
</script>
</head>
<body>
</body>
</html>
Related examples in the same category