Orchestrator Function: Sort an Array of vCenter Managed Entity by any Property Value

by Simon Sparks · 20 January 2026

To use this function add it to the class library file named vCenterServerService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: vCenterServerService.ts

Function VcManagedEntitySort

Description: Orchestrator Function to Sort an Array of VcManagedEntity by any Property Value

publicVcManagedEntitySort<T>(arrVcManagedEntity:T[],enumSortOrder:SortOrder,strPropertyName:string="name"):T[]{
if (enumSortOrder===SortOrder.Forward){

arrVcManagedEntity=arrVcManagedEntity.sort((objVcManagedEntityA:T,objVcManagedEntityB:T):1| -1|0=>{

returnUtilities.compareTwoString(objVcManagedEntityA[strPropertyName],objVcManagedEntityB[strPropertyName],enumSortOrder);

});
}
elseif (enumSortOrder===SortOrder.Reverse){

arrVcManagedEntity=arrVcManagedEntity.sort((objVcManagedEntityA:T,objVcManagedEntityB:T):1| -1|0=>{

returnUtilities.compareTwoString(objVcManagedEntityB[strPropertyName],objVcManagedEntityA[strPropertyName],enumSortOrder);

});
}

returnarrVcManagedEntity;
}

Enumeration: SortOrder

exportenumSortOrder{
Forward="Forward",
Reverse="Reverse"
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like