import { Collector } from "../collector"; import { Comparator } from "../queries/math"; import { toArray } from "../collections/toArray"; export function sorting ( comparator : Comparator, collector : Collector ) : Collector; export function sorting ( comparator ?: Comparator ) : Collector; export function sorting ( comparator ?: Comparator, collector ?: Collector ) : Collector { return toArray().then( arr => { arr.sort( comparator ); if ( collector ) { return collector.apply( arr ); } else { return arr as any as R; } } ); }