shap.utils.hclust_ordering

shap.utils.hclust_ordering(X, metric='sqeuclidean', anchor_first=False)

A leaf ordering is under-defined, this picks the ordering that keeps nearby samples similar.