SQLite Forum

ORDER BY not working for a specific DB/table
Login
A database containing just one table with following schema

    CREATE TABLE latiSaltxi (westCCod, lati10, longi);

The following select should result in records sorted first by lati10 and then longi

      SELECT *
      FROM latiSaltxi 
      WHERE lati10 >= 41 AND lati10 <= 41.3 
      ORDER BY lati10, longi

in general it does but not for all values, for example when arriving at lat10 41.2 at some point is not sorted (e.g. -73 < than 129)

      ...
      392|41.1|140.83551
      392|41.1|141.396450589127
      380|41.2|9.37497676257462
      380|41.2|16.6342872848924
      792|41.2|43.2255548289229
      860|41.2|66.7126410609169
      408|41.2|129.727571723508
      840|41.2|-73.970001
      840|41.2|-73.964172
      840|41.2|-73.964172

all values are numeric so it does not help adding +0 to all columns in the query (tried)

But if the filter is set to start with this particular value 
 
       WHERE lati10 >= 41.2 ..

then the result is sorted!

     840|41.2|-73.970001
     840|41.2|-73.964172
     840|41.2|-73.964172
     840|41.2|-73.955566
     840|41.2|-73.955566
     840|41.2|-73.9538569733247
     ...

Dumping the database and building a new one with sqlite3.exe does not help.

This behavior happens with any sqlite version (last tested 3.31.1)
It is very strange, probably I am missing something but right now I cannot figure out what.

I can provide the particular data if needed (~ 1 MB 7zipped)