comparison of negative numbers turn out wrong
<p>I am doing a test of position bounding boxes, but when comparing negative (south or west) positions with other negative positions it turns the result upside down.</p>

<pre><code>if minlat &gt; maxlat:
    minlat, maxlat = swap(minlat, maxlat)
if minlon &gt; maxlon:
    minlon, maxlon = swap(minlon, maxlon)
</code></pre>

<p>This works fine when comparing latitudes on northern hemisphere or positions on southern with northern hemisphere, but when comparing positions on southern hemisphere it turns them around (i.e., -20.4 is less than -20.8). Is there a simple solution to this, or must I make a different test if both values are less than 0?</p>

<p>generally you'll want to compare the absolute values rather than the actual values in this scenario, try</p>

<pre><code>if abs(minlat) &gt; abs(maxlat):
</code></pre>

<p>good luck!</p>

python python-2.7