[SERVER-12211] sort function not working well Created: 28/Dec/13  Updated: 10/Dec/14  Resolved: 28/Dec/13

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.4.8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Rajnish Kumar Assignee: Unassigned
Resolution: Done Votes: 0
Labels: datetime, mongodb, sorting
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ubuntu 12.04


Operating System: Linux
Participants:

 Description   

Hi Team,
I am running mongodb on my production server ,mongodb version is 2.4.8.
I have a collections in which I am storing datetime in every records ,but when i am sorting the results based on that column it result is not correct . Below are the details result with query . Please tell me where I was wrong ?

db.version() ;
2.4.8
> db.raw_process.find(

{"Username" : "tmp123@test123.com"}

,

{"ServerTimestamp":1,"_id":0}

).sort(

{"$ServerTimestamp" :-1}

).pretty() ;
result are below :

{ "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:40:21.115Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:41:44.955Z") }

Type "it" for more
> it

{ "ServerTimestamp" : ISODate("2013-12-28T12:42:05.801Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:05.802Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") } { "ServerTimestamp" : ISODate("2013-12-28T12:42:32.369Z") }

 Comments   
Comment by Rajnish Kumar [ 28/Dec/13 ]

Hi ,
Sorry I got error , its my mistake I used $ in sort .

Generated at Thu Feb 08 03:27:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.