Hi,
I would like to sort a VM array by their resource pool.
I have tried a couple of things from various searches but none of them seem to work, but I can not find much reference material.
where WindowsVMs is an Array/VC:VirtualMachine
WindowsVMs = WindowsVMs.sort(sortVMs);
I have tried both of these functions, I have also tried the same with VM name as the sort criteria. Neither seem to work and the System.log does not create an entry.
function sortVMs(a,b) {
return (a.resourcePool.name > b.resourcePool.name);
System.log("0:NO");
}
function sortVMs(a,b) {
var vmA=a.resourcePool.name.toLowerCase();
var vmB=a.resourcePool.name.toLowerCase();
if (vmA < vmB) { //sort string ascending
return -1
System.log( "-1 A<B");
}
if (vmA > vmB) {
return 1
System.log( "1 A>B");
}
return 0 //default return value (no sorting)
System.log("0:NO");
}
Any thoughts?
Regards
Mark