What would i need to put in the SortIP
function to make the custom sort function sort the array by the last digit of the IP number. This doesn't work.
function SortIP(a, b)
{
return a[0][3] - b[0][3];
}
LAN = new Array
(
["ADSL Router", [192, 168, 0, 1]],
["Gary's Mac", [192, 168, 0, 15]],
["Network Switch", [192, 168, 0, 2]],
["Production Email", [192, 168, 0, 60]]
);
LAN.sort(SortIP);
expected array order:
- ADSL Router: 192.168.0.1
- Network Switch: 192.168.0.2
- Gary's Mac: 192.168.0.15
- Production Email: 192.168.0.60