title: sort query for array structure in mongodb
body: <p>I have a document having array structure in MongoDB.
  How can I sort the array element in ascending order?</p>
  
  <p>The below is the Input:</p>
  
  <pre><code>{
      "id": 1,
      "name": "sanjay",
      "address": "Odisha",
      "shoes": [
          {
              "brand": "puma",
              "size": "10"
          },
          {
              "brand": "bata",
              "size": "11"
          },
          {
              "brand": "rebook",
              "size": "9"
          },
          {
              "brand": "adidas",
              "size": "7"
          },
          {
              "brand": "bata",
              "size": "8"
          }
      ]
  }
  </code></pre>
  
  <p>Can anyone help me to get a query to sort my all array element in ascending order of the key "size"?</p>
  
  <p>The below is the required output.</p>
  
  <pre><code>{
      "id": 1,
      "name": "sanjay",
      "address": "Odisha",
      "shoes": [
          {
              "brand": "adidas",
              "size": "7"
          },
          {
              "brand": "bata",
              "size": "8"
          },
          {
              "brand": "rebook",
              "size": "9"
          },
          {
              "brand": "puma",
              "size": "10"
          },
          {
              "brand": "bata",
              "size": "11"
          }
      ]
  }
  </code></pre>
  
  <p>Could you please help me to find out the exact query?</p>
  
  <p>Regards,
  Sanjay</p>