Hi,
First off, I am new to Javascript.
I have the following javascript code, and I want to sort my HostList Array by Host name.
I tried the Array.sort(); function, but since it is objects, and not a list of hostnames. The result is done by Host name.
Does anyone know how to achieve the desired result?
/Brian
--------------------------------------
var allHosts = VcPlugin.getAllHostSystems();
HostNameToMatch = "ESXi";
var hosts = new Array();
for (var i in allHosts) {
if (allHosts[i].name.match(new RegExp(HostNameToMatch, "i"))) {
hosts.push(allHosts[i]);
}
}
HostList = hosts;
HostList.sort();
--------------------------------------