Function: Sort an Array of Strings

by Simon Sparks · 20 January 2026

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(arr: string[], enumSortOrder: SortOrder = SortOrder.Forward): string[] {
  arr = arr.sort((strA: string, strB: string): 1 | -1 | 0 => {
    return Utilities.compareTwoString(strA, strB, enumSortOrder);
  });

  return arr;
}

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.

You may also like