Convex hull: Difference between revisions

Line 1,611:
</pre>
 
Also if we swap points A and B then result will be different (!). Probably the problem is that when we use p.sort() we sort only by x - but for case when A.x == B.x we should also sort by y (like in e.g. JavaScript version). So below code in class Point method compareTo probably should be used
<pre>
override fun compareTo(other: Point): Int {
val x = this.x.compareTo(other.x)
if (x==0) {
return this.y.compareTo(other.y)
} else {
return x
}
}
</pre>
 
=={{header|Lua}}==
Anonymous user