Sort IDs before assigning them indices in NetworkInfo.

This commit is contained in:
Andreas Fackler 2019-12-18 10:01:38 +01:00 committed by Andreas Fackler
parent e43baa4b8b
commit 4857b7f9c7
1 changed files with 3 additions and 1 deletions

View File

@ -21,7 +21,9 @@ where
N: NodeIdT,
{
fn from(i: I) -> Self {
let indices: BTreeMap<N, usize> = i
let mut ids: Vec<N> = i.into_iter().map(|id| id.borrow().clone()).collect();
ids.sort();
let indices: BTreeMap<N, usize> = ids
.into_iter()
.enumerate()
.map(|(n, id)| (id.borrow().clone(), n))