I want to update an array containing lat,lng values.my update query from python is given below.
client.mydb.mycoll.update({"_id":123},{'$push':{"loc":{"lng":77.77,"lat":12.12}}} )
the collection already have some value in "loc" array as follows
{ "_id" : 123, "loc" : [ { "lng" : 77.6104193, "lat" : 12.9264116 } ], "name" : "myname" }
the problem with update query is that it store the new "loc" element as
{ "_id" : 123, "loc" : [ { "lng" : 77.6104193, "lat" : 12.9264116 },{"lat":12.12,"lng":77.77} ], "name" : "myname" }
I need to store loc data in the order "lng" fist and then "lat".so that later, I can query using $near operator ({loc:{$near:[77.77,12.12]}}).python dictionary always store key value pair sorted according to key.how can I do it?