Function caseInsensitiveSort

  • Provides a shorthand for sorting arrays of complex objects by a string property

    Parameters

    • prop: string

      Name of property to use, supports dot notation

    Returns ((a: any, b: any) => number)

    • Function to handle sort (Meant to be passed to Array.prototype.sort or used in sortFn)
      • (a, b): number
      • Parameters

        • a: any
        • b: any

        Returns number

    let arr = [{a: 'Apple', b: 123}, {a: 'Carrot', b: 789}, {a: 'banana', b: 456}];
    arr.sort(caseInsensitiveSort('a'));