title: Reverse array field in MongoDB
body: <p>I have a collection with a location field that was entered in the wrong order:</p>
  
  <pre><code>location: [38.7633698, -121.2697997]
  </code></pre>
  
  <p>When I try to place a 2d index on the field using ...</p>
  
  <pre><code>db.collection.ensureIndex({'location': '2d'});
  </code></pre>
  
  <p>... I get the following error because the latitude and longitude are reversed.</p>
  
  <pre><code>"err" : "location object expected, location array not in correct format",
  "code" : 13654
  </code></pre>
  
  <p>How can I reverse this array for each document in the mongo shell?</p>