Documentation
    Preparing search index...

    Function sortHitsByDistance

    • Sorts hits by ascending distance in place and returns the same array (§30 "sorted hits").

      Array.prototype.sort is stable per the language specification, so hits at an identical distance keep the adapter's traversal order rather than being permuted — which is what makes a sorted query result reproducible from step to step (§33). Mutates and returns the argument instead of allocating, matching the engine's allocation policy (§7b/D7) for a call that happens per query.

      Type Parameters

      • T extends { distance: number }

      Parameters

      • hits: T[]

      Returns T[]