Array ordering semantics are different with index than without an index

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.9.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      > db.c.save(

      {a:[1,10]}

      );
      > db.c.save(

      {a:5}

      );
      > db.c.find().sort(

      {a:1}

      )

      { "_id" : ObjectId("4d95731036d6ac4c79650e64"), "a" : 5 } { "_id" : ObjectId("4d95730836d6ac4c79650e63"), "a" : [ 1, 10 ] }

      > db.c.find().sort(

      {a:-1}

      )

      { "_id" : ObjectId("4d95730836d6ac4c79650e63"), "a" : [ 1, 10 ] } { "_id" : ObjectId("4d95731036d6ac4c79650e64"), "a" : 5 }

      > db.c.ensureIndex(

      {a:1}

      );
      > db.c.find().sort(

      {a:1}

      )

      { "_id" : ObjectId("4d95730836d6ac4c79650e63"), "a" : [ 1, 10 ] } { "_id" : ObjectId("4d95731036d6ac4c79650e64"), "a" : 5 }

      > db.c.find().sort(

      {a:-1}

      )

      { "_id" : ObjectId("4d95730836d6ac4c79650e63"), "a" : [ 1, 10 ] } { "_id" : ObjectId("4d95731036d6ac4c79650e64"), "a" : 5 }

      >

            Assignee:
            Aaron Staple (Inactive)
            Reporter:
            Aaron Staple (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: