turn/ttorrent — pull request #65 by pwoodworth (2013-09-20 05:43:21+00:00)
Title: Fix Piece compareTo ordering

This is a fix for the case of Piece.compareTo returning inconsistent ordering.

Specifically if you have (pseudocode):

Piece p1, p2;
p1.seen = p2.seen =

Then you'd would see with the old code:

p1.compareTo(p2) == p2.compareTo(p1) == 1

This is wrong and will give headaches to sorting algorithms. One of those should be -1, they should only be equal when they both return 0. The new code provides consistent ordering by seen then index.