[DOCS-3955] Sorting only sorts first digit of multi digit numbers Created: 27/Aug/14  Updated: 29/Aug/14  Resolved: 29/Aug/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.10

Type: Improvement Priority: Trivial - P5
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/reference/operator/aggregation/group/
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0
Referrer: http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CCwQFjAC&url=http%3A%2F%2Fdocs.mongodb.org%2Fmanual%2Freference%2Foperator%2Faggregation%2Fgroup&ei=yRr-U8-cI9WlyATBloGYDQ&usg=AFQjCNFJDMDdcu1O-ymAezNlFaOFG8qXWg&bvm=bv.74035653,d.aWw
Screen Resolution: 2144 x 1340
repo: docs
source: reference/operator/aggregation/group


Participants:
Days since reply: 9 years, 24 weeks, 6 days ago

 Description   

Hello when I use $sort in an aggregation it only seems to sort by the first digit of the according field..
E-mail: morelli3@llnl.gov



 Comments   
Comment by Kay Kim (Inactive) [ 28/Aug/14 ]

Hi –
could you provide a sample of the dataset you are using. I am able to sort by multi-digit numbers.

> db.myagg.aggregate(  [{ $sort: { a: 1 } }] )
{ "_id" : ObjectId("53ffb7c1c3ba2220c65af766"), "a" : 10 }
{ "_id" : ObjectId("53ffb7c4c3ba2220c65af767"), "a" : 20 }
{ "_id" : ObjectId("53ffb7c8c3ba2220c65af768"), "a" : 100 }
{ "_id" : ObjectId("53ffb7cac3ba2220c65af769"), "a" : 1000 }
> db.myagg.aggregate( [ { $sort: { a: -1 } } ] )
{ "_id" : ObjectId("53ffb7cac3ba2220c65af769"), "a" : 1000 }
{ "_id" : ObjectId("53ffb7c8c3ba2220c65af768"), "a" : 100 }
{ "_id" : ObjectId("53ffb7c4c3ba2220c65af767"), "a" : 20 }
{ "_id" : ObjectId("53ffb7c1c3ba2220c65af766"), "a" : 10 }

Generated at Thu Feb 08 07:46:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.