in src/dataViewBuilder/matrixBuilder.ts [310:326]
private insertInSortedOrder(node: powerbi.DataViewMatrixNode, list: powerbi.DataViewMatrixNode[]): void {
for (let i = 0; i < list.length; i++) {
let currNode = list[i];
for (let j = 0; j < currNode.levelValues.length; j++) {
let comparison = this.compareValue(node.levelValues[j].value, currNode.levelValues[j].value);
if (comparison < 0) {
list.splice(i, 0, node);
return;
}
else if (comparison > 0) {
break;
}
}
}
list.push(node);
}