summaryrefslogtreecommitdiff
path: root/jstests/sort6.js
blob: 3fa8a923ada00fca09253eb49b793bc5b9abc5c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

t = db.sort6;
t.drop();

t.insert({_id:1})
t.insert({_id:2})
t.insert({_id:3,c:1})
t.insert({_id:4,c:2})

function get( x ){
    return t.find().sort( { c : x } ).map( function(z){ return z._id; } );
}

//assert.eq( [4,3,2,1] ,  get( -1 ) , "A1"  )
assert.eq( [1,2,3,4] , get( 1 ) , "A2" )

t.ensureIndex( { c : 1 } );

assert.eq( [4,3,2,1] ,  get( -1 ) , "B1"  )
assert.eq( [1,2,3,4] , get( 1 ) , "B2" )