Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3941418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:32:26+00:00 2026-05-20T00:32:26+00:00

results = docDB.posts.find({active:True }).sort(pop_score, pymongo.DESCENDING) This is my sort right now. But the problem

  • 0
results = docDB.posts.find({"active":True }).sort("pop_score", pymongo.DESCENDING)

This is my sort right now. But the problem is, some things have the same “score”. In that case, if they tie, I want them to sort by “time” within the ones who tied.

How do I do that? It’s possible to do that in Mysql…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:32:26+00:00Added an answer on May 20, 2026 at 12:32 am

    You can sort by more than one attribute at a time. e.g.

    sort({name : 1, age : -1})
    

    will sort by name ascending then by age descending

    See here for reference: http://www.mongodb.org/display/DOCS/Sorting+and+Natural+Order

    Edit:

    In pymongo, that would be

    .sort([['name', pymongo.ASCENDING], ['age', pymongo.DESCENDING]])
    

    referenceL http://api.mongodb.org/python/current/api/pymongo/cursor.html#pymongo.cursor.Cursor.sort

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Google results on this one are a bit thin, but suggest that it is
the results look like this but wher the column name says 'Today' I want
I copy search results of Google and want to stick it on Excel now.
I fetched the results of a query in the model. Next i right away
This following code results in this output, I cant see my text view. What
I understand this has been discussed before but since this post in late 2010
@search_results = Array.new duplicates = Set.new results.each { |result| @search_results.push(result) unless duplicates.add?(result[:url]) } This
results = Content.objects.filter(next_decay_at__lte=datetime.datetime.now())
ViewData[results] = indication.Model.prepaymentList; return View(@~\Views\Indications\TermSheetViews\Swap\PrePayment.aspx, indication.Model); This works fine but my compilation error is
results.Where(x=>x.Members.Any(y=>members.Contains(y.Name.ToLower()) I happened to see this query in internet. Can anyone explain this query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.