// //testing $sort aggregation pipeline for heterogeneity (SERVER-6125) //method: // Create an array with all the different types. (Array is created with correct sort order) // Randomise it (to prevent $sort returning types in same order). // Save the array members to the db. // aggregate($sort) // iterate through the array ensuring the _ids are in the correct order //to make results array nested (problem 2) function nestArray( nstArray ) { for( x = 0; x < nstArray.length; x++ ) { nstArray[x].a = { b : nstArray[x].a }; } } //sort and run the tests function runSort( chkDoc, nest, problem ){ var chkArray = setupArray(); if( nest ){ nestArray( chkArray ); } Array.shuffle(chkArray); var t = db.s6125; t.drop(); t.insert( chkArray ); runAsserts( t.aggregate( { $sort : chkDoc } ).toArray(), problem ); } //actually run the tests function runAsserts( chkArray, problem ) { //check the _id at [0] to determine which way around this has been sorted //then check for gt / lt. Done rather than neq to preclude a < b > c issues if( chkArray[ 0 ]._id == 0 ) { for( var x=0; x