• Provides a shorthand for sorting arrays of complex objects

    Parameters

    • prop: string

      Name of property to use, supports dot notation

    • reverse: boolean = false

      Reverse the order of the sort

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

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

        • a: any
        • b: any

        Returns number

    let arr = [{a: {b: 2}}, {a: {b: 3}}, {a: {b: 1}}];
    arr.sort(sortByProp('a.b'));