Created
August 31, 2016 12:20
-
-
Save jkomyno/be38df107b24d45922f67aa17c4df3c4 to your computer and use it in GitHub Desktop.
Utility to sort three correlated array by merging them temporarily into objects. This utility sorts according to srttList (the third array).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function threeArraySort(ipList, macList, srttList) { | |
var list = []; | |
for (var j in ipList) | |
list.push({'ip': ipList[j], 'mac': macList[j], 'srtt': srttList[j] }); | |
list.sort(function(a, b) { | |
return ((a.srtt < b.srtt) ? -1 : ((a.srtt == b.srtt) ? 0 : 1)); | |
}); | |
for (var k = 0; k < list.length; k++) { | |
ipList[k] = list[k].ip; | |
macList[k] = list[k].mac; | |
srttList[k] = list[k].srtt; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment