import { IComparer } from "../../types" ; import { asKeyMap } from "./asKeyMap" ; param source param keySelector param ascending param comparer export function * asSortedKeyValues < TSource , TKey > ( source , keySelector , ascending , comparer ? ) { const map = asKeyMap ( source , keySelector ) ; const sortedKeys = [ ... map . keys ( ) ] . sort ( comparer ? comparer : undefined ) ; if ( ascending ) { for ( let i = 0 ; i < sortedKeys . length ; i ++ ) { yield map . get ( sortedKeys [ i ] ) as TSource [ ] ; } } else { for ( let i = sortedKeys . length - 1 ; i >= 0 ; i -- ) { yield map . get ( sortedKeys [ i ] ) as TSource [ ] ; } } }