From ef152e58174ac2ad1c0eea45462532d1d07dcaf8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20B=C3=A9daride?= Date: Tue, 29 Jan 2013 18:51:08 +0100 Subject: [PATCH] Fix kademlia node sort --- examples/msg/kademlia/answer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } /** -- 2.20.1