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 8765073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:11:49+00:00 2026-06-13T16:11:49+00:00

I have a case that looks like this: I have a collection called for

  • 0

I have a case that looks like this:
I have a collection called for example “Test” and I have set up an index for it and the index looks something like this:

{
 "A" : 1,
 "B" : 1,
 "C" : 1
}

In my code I am retrieving the records based on “A” being a certain value:

List<Test> tests = Test.Find(Query.EQ("A", CertainValue)).ToList();

And to my surprise all the records are coming back sorted in the order mentioned in the index (“B” ascending then “C” ascending)

I was wondering if this behavior is always to be expected, is the records always going to be sorted based on the index, or am I just imagining stuff and this is just a one off case?

PS. The Records are NOT entered into the collection sorted so this is not the natural order of the records.

  • 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-06-13T16:11:50+00:00Added an answer on June 13, 2026 at 4:11 pm

    Just as with many other dictionary implementations, order in database is not defined or guaranteed (except for capped collections) and subject to change at any time:

    “Natural order” is defined as the database’s native ordering of
    objects in a collection.

    When executing a find() with no parameters, the database returns
    objects in forward natural order.

    For standard tables, natural order is not particularly useful because,
    although the order is often close to insertion order, it is not
    guaranteed to be. However, for Capped Collections, natural order is
    guaranteed to be the insertion order.

    Use explicit sort if you need them sorted in some way or refer to your particular driver (C#) implementation docs to see if it sorts them for you.

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

Sidebar

Related Questions

I have code that looks like this: function foobar(array& $objects, $con = null) {
I have a piece of xml that looks something like <SubscriptionProduct> <SubscriptionProductIdentifier> <SubscriptionProductIdentifierType> <SubscriptionProductIDType>01</SubscriptionProductIDType>
I have a pair of classes that look something like this. There's a Generator
I have a save function for my order entity that looks like this and
I have a regular .NET application. In this case I have a part that's
I have several large enums that are used like switch(someEnumValue) { case SomeEnum.Value1: DoSomething();
Very strange issue... I have something like this in my Controller: public ActionResult Initialize(IEnumerable<MyModel>
I have a python script called mythicalPythonBindings.py. It outputs something like Establishing database connection
I have a code like this: public abstract class DataContextBase { public DbContext DbContext
I have an application that manages documents called Notes. Like a blog, Notes can

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.