Unindexed array field sorts incorrectly

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.7.4
    • Component/s: Querying
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      //wrong order
      db.games.find().sort(

      {'decks.points': -1}

      );
      { "_id" : "game-20101124-185512-c86779ce.html", "decks" : [

      { "points" : 64 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-171239-da3d89e2.html", "decks" : [

      { "points" : 63 }

      ,

      { "points" : 33 }

      ] }
      { "_id" : "game-20101124-204302-026f72ee.html", "decks" : [

      { "points" : 43 }

      ,

      { "points" : 36 }

      ,

      { "points" : 28 }

      ] }
      { "_id" : "game-20101124-083714-3cc1743c.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-013048-26973e9a.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 29 }

      ] }

      db.games.ensureIndex(

      {"decks.points": -1}

      )

      //correct order
      db.games.find().sort(

      {'decks.points': -1}

      );
      { "_id" : "game-20101124-185512-c86779ce.html", "decks" : [

      { "points" : 64 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-171239-da3d89e2.html", "decks" : [

      { "points" : 63 }

      ,

      { "points" : 33 }

      ] }
      { "_id" : "game-20101124-083714-3cc1743c.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 42 }

      ] }
      { "_id" : "game-20101124-013048-26973e9a.html", "decks" : [

      { "points" : 47 }

      ,

      { "points" : 29 }

      ] }
      { "_id" : "game-20101124-204302-026f72ee.html", "decks" : [

      { "points" : 43 }

      ,

      { "points" : 36 }

      ,

      { "points" : 28 }

      ] }
      > db.decks.dropIndex(

      {'decks.points':-1}

            Assignee:
            Unassigned
            Reporter:
            Scott Hernandez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: