• Given a source object to sort, a target to sort relative to, and an Array of siblings in the container: Determine the updated sort keys for the source object, or all siblings if a reindex is required. Return an Array of updates to perform, it is up to the caller to dispatch these updates. Each update is structured as: { target: object, update: {sortKey: sortValue} }

    Parameters

    • source: object

      The source object being sorted

    • Optionaloptions: {
          siblings?: object[];
          sortBefore?: boolean;
          sortKey?: string;
          target?: null | object;
      } = {}

      Options which modify the sort behavior

      • Optionalsiblings?: object[]

        The Array of siblings which the source should be sorted within

      • OptionalsortBefore?: boolean

        Explicitly sort before (true) or sort after( false). If undefined the sort order will be automatically determined.

      • OptionalsortKey?: string

        The property name within the source object which defines the sort key

      • Optionaltarget?: null | object

        The target object relative which to sort

    Returns object[]

    An Array of updates for the caller of the helper function to perform