Question: I am having a db, having 3000 values and each value contains approx 10 fields, now when i try to sort the values by a particular field, it only sort up to a limit and shows a value. 
Like here in Robomongo i am trying to sort a value named NET\_TURNOV which you can see in photo 9990
The command which i have used is:

```
db.getCollection('col').find({}).sort({"NET_TURNOV": -1})

```

[![sorting by NET_TURNOV](https://i.stack.imgur.com/k0wo8.png)](https://i.stack.imgur.com/k0wo8.png)

However, in this next photo you can see the same db having higher value of NET\_TURNOV, why this is happening.
here is the next photo
[![enter image description here](https://i.stack.imgur.com/HbFqm.png)](https://i.stack.imgur.com/HbFqm.png)

Answer: 
Your NET\_TURNOV (and all other numbers) are stored as strings. This explains the "weird" sorting.

Number `22` is greater than number `9`, but *string* `"22"` is less than string `"9"` (because they're compared character by character).

Numbers should be stored as numbers, if you want to do any number-y stuff on them, like sorting, or finding maximum, or adding/subtracting them, etc. Which is to say "always".
In my case, the field `timestamp` was a number `double` but somehow Mongo was interpreting it as a string. I don't know why but after upgrading from Mongo 3.2 to 3.4 this disappeared. 

UPDATE

Okay, so I have finally nailed it!

WRONG

```
model.find({query},function(err, docs){
    //docs sorted on OSX but not on Ubuntu
    //documents are listed before the sorting happens
}).sort('timestamp');

```

CORRECT

```
model.find({query})
.sort('timestamp')
.exec(function(err, docs){
   //docs sorted on both systems
});

```

CORRECT

```
model.find({query})
.sort('timestamp')
.then(function(docs){
   //docs in right order
})
.catch(function(error){});

```