From: Paul Bédaride Date: Tue, 29 Jan 2013 17:51:08 +0000 (+0100) Subject: Fix kademlia node sort X-Git-Tag: v3_9_rc1~25^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8e9f3ce9f2e2546fe06f3a2057c17770ca755895 Fix kademlia node sort --- diff --git a/examples/msg/kademlia/answer.c b/examples/msg/kademlia/answer.c index 4eb095f620..712b6fa760 100644 --- a/examples/msg/kademlia/answer.c +++ b/examples/msg/kademlia/answer.c @@ -78,7 +78,13 @@ static int _answer_sort_function(const void *e1, const void *e2) { node_contact_t c1 = *(void **) e1; node_contact_t c2 = *(void **) e2; - return c1->distance >= c2->distance; + if (c1->distance == c2->distance) + return 0; + else + if (c1->distance < c2->distance) + return -1; + else + return 1; } /**