Function objSortKeys

  • Sorts the keys of an object in alphabetical order.

    Type Parameters

    • V

    Parameters

    • o: Record<ObjectKey, V>

      The object whose keys should be sorted.

    Returns Record<ObjectKey, V>

    A new object with the same values as the original, but with keys sorted in ascending order.

    Remarks

    This function does not mutate the original object. It returns a new object with sorted keys.

    Typeparam

    V - The type of the values in the object.

    Example

    const obj = { c: 1, a: 2, b: 3 };
    objSortKeys(obj);
    //=> { a: 2, b: 3, c: 1 }

Generated using TypeDoc