@itwin/presentation-hierarchies
Version:
A package for creating hierarchies based on data in iTwin.js iModels.
22 lines • 1.1 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { concatAll, map, reduce } from "rxjs";
import { DuplicatePolicy, SortedArray } from "@itwin/core-bentley";
import { compareNodesByLabel } from "../Common.js";
/**
* This should accept sorting params in some form:
* - is sorting disabled?
* - are we sorting by label or some property value, in case of the latter - how do we get the value?
*
* @note Nodes with same labels are returned in undefined order.
* @internal
*/
export function sortNodesByLabelOperator(nodes) {
return nodes.pipe(reduce((sorted, node) => {
sorted.insert(node);
return sorted;
}, new SortedArray(compareNodesByLabel, DuplicatePolicy.Allow)), map((sortedArray) => sortedArray.extractArray()), concatAll());
}
//# sourceMappingURL=Sorting.js.map