Creating a custom array within an array sort function in Javascript -
In order to sort arrays to the custom sort function, I have to enter in the SortIP
function. This does not work from the last digit of the number.
function ccupi (A, B) {back [0] [3] - B [0] [3]; } "Network switch", ["ADSL router", [192, 168, 0, 1]], ["Gary Mack", [192, 168, 0, 15]], [192, 168, 0, 2]], ["production email", [192, 168, 0, 60]]); LAN.sort (SortIP); Network Switch: 192.168.0.2 Gary Mack: 192.168.0.15 Product Email: 192.168.0.60
you are almost there
just replaced
back [0] [3] - b [0] [3];
with
back [1] [3] - b [1] [3];
And you are
Why? Because IP is the second (index = 1) cell of each array.
Comments
Post a Comment