dist/async-iterable/operators.js
function orderBy(keySelector, comparison) {
    const trueKeySelector = keySelector || defaultKeySelector;
    const trueComparison = comparison || defaultComparison;
    return function (item) {
        return __asyncGenerator(this, arguments, function* () {
            var e_25, _a;
            const keyedMapper = map((item, index) => ({ item, key: trueKeySelector(item, index) }));
            const keyed = keyedMapper(item);
            const keyedArray = yield __await(toWriteableArray(keyed));
            keyedArray.sort((a, b) => trueComparison(a.key, b.key));
            try {
                for (var keyedArray_1 = __asyncValues(keyedArray), keyedArray_1_1; keyedArray_1_1 = yield __await(keyedArray_1.next()), !keyedArray_1_1.done;) {
                    const { item } = keyedArray_1_1.value;
                    yield yield __await(item);
                }
            }
            catch (e_25_1) { e_25 = { error: e_25_1 }; }
            finally {
                try {
                    if (keyedArray_1_1 && !keyedArray_1_1.done && (_a = keyedArray_1.return)) yield __await(_a.call(keyedArray_1));
                }
                finally { if (e_25) throw e_25.error; }
            }
        });
    };
}
function orderBy(keySelector, comparison) {
    const trueKeySelector = keySelector || defaultKeySelector;
    const trueComparison = comparison || defaultComparison;
    return function (item) {
        return __asyncGenerator(this, arguments, function* () {
            var e_25, _a;
            const keyedMapper = map((item, index) => ({ item, key: trueKeySelector(item, index) }));
            const keyed = keyedMapper(item);
            const keyedArray = yield __await(toWriteableArray(keyed));
            keyedArray.sort((a, b) => trueComparison(a.key, b.key));
            try {
                for (var keyedArray_1 = __asyncValues(keyedArray), keyedArray_1_1; keyedArray_1_1 = yield __await(keyedArray_1.next()), !keyedArray_1_1.done;) {
                    const { item } = keyedArray_1_1.value;
                    yield yield __await(item);
                }
            }
            catch (e_25_1) { e_25 = { error: e_25_1 }; }
            finally {
                try {
                    if (keyedArray_1_1 && !keyedArray_1_1.done && (_a = keyedArray_1.return)) yield __await(_a.call(keyedArray_1));
                }
                finally { if (e_25) throw e_25.error; }
            }
        });
    };
}
Play the given AsyncIterable ordered by a given key or itself