public int Compare(Pair <State, float> o1, Pair <State, float> o2) { float previous = o1.GetRight(); float d1 = _distance[o1.GetLeft().GetId()]; float next = o2.GetRight(); float d2 = _distance[o2.GetLeft().GetId()]; float a1 = _semiring.Times(next, d2); float a2 = _semiring.Times(previous, d1); if (_semiring.NaturalLess(a1, a2)) { return(1); } if (a1 == a2) { return(0); } return(-1); }