import type { SortOpts , Transducer } from "./api.js" ; import { comp } from "./comp.js" ; import { __sortOpts } from "./internal/sort-opts.js" ; import { __iter , iterator } from "./iterator.js" ; import { mapcat } from "./mapcat.js" ; import { partition } from "./partition.js" ; /**
 * Transducer. Composition of  {@link (partition:1)} and
 *  {@link (mapcat:1)} which yields a **partially** sorted sequence of
 * input values. Sorting is performed on sliding / non-overlapping
 * chunks of `n` inputs.
 *
 *  remarks example param n param key param cmp export function partitionSort < A , B > ( n , opts ? ) ; export function partitionSort < A , B > ( n , src ) ; export function partitionSort < A , B > ( n , opts , src ) ; export function partitionSort < A , B > ( ... args ) { const iter = __iter ( partitionSort , args , iterator ) ; if ( iter ) { return iter ; } const { key , compare } = __sortOpts < A , B > ( args [ 1 ] ) ; return comp < A , A [ ] , A > ( partition ( args [ 0 ] , true ) , mapcat ( ( window ) => window . slice ( ) . sort ( ( a , b ) => compare ( key ( a ) , key ( b ) ) ) ) ) ; }