To use this function add it to the class library file named Utilities.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: Utilities.ts
Function sortArrayOfString
Description: Orchestrator Function to Sort an Array of Strings
public static sortArrayOfString(strA: string, strB: string, enumSortOrder: SortOrder = SortOrder.Forward): 1 | -1 | 0 {
if (enumSortOrder === SortOrder.Forward) {
if (strA < strB) {
return -1;
} else if (strA > strB) {
return 1;
} else {
return 0
}
} else if (enumSortOrder === SortOrder.Reverse) {
if (strA < strB) {
return 1;
} else if (strA > strB) {
return -1;
} else {
return 0
}
}
}Enumeration: SortOrder
export enum SortOrder {
Forward = "Forward",
Reverse = "Reverse"
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
