• Deep sort the properties of an object by their key name and return a new object with the sorted properties.

    Parameters

    • obj: unknown

      Object to sort

    • Optional compareFn: ((a, b) => number)

      Optional compare function to use when sorting the properties; defaults to a.localeCompare(b, 'en')

        • (a, b): number
        • Parameters

          • a: [key: string, value: unknown]
          • b: [key: string, value: unknown]

          Returns number

    • Optional options: {
          sortOrder?: "asc" | "desc";
      }

      Optional options to control the sort order; defaults to asc

      • Optional sortOrder?: "asc" | "desc"

    Returns any

    New object with the sorted properties