title: CouchDB mango ignoring index sort order
body: <p>I am using Hyperledger Fabric with CouchDB (version 2.2.0, the one that comes with the hyperledger/fabric-couchdb docker image). There is a limitation on Fabric which does not allow to specify sort array for mango queries, so it has to be done with indexes.</p>
  
  <p>The problem I am facing is that no matter if I specify sort "asc" or "desc" fot the index fields, the query results always come in the same order.</p>
  
  <p>The index I am trying to create (also I would rather use assetType as partial index selector, but had no success on that too):</p>
  
  <pre class="lang-js prettyprint-override"><code>{
      "index": {
        "fields": [
          {"assetType": "desc"},
          {"originalCustomer.document":"desc"}, 
          {"transactionDate":"desc"}
        ]
      },
      "ddoc": "date-index",
      "name": "date-index",
      "type": "json"
   }
  </code></pre>
  
  <p>Query I am running</p>
  
  <pre class="lang-js prettyprint-override"><code>{
      "selector": {
          "assetType": "receivable",
          "originalCustomer.document": "1",
          "transactionDate": {
              "$gt":"1900-01-01"
          }
      },
      "use_index": ["date-index"]
   }
  </code></pre>
  
  <p>_explain result</p>
  
  <pre class="lang-js prettyprint-override"><code>{
      "dbname": "testdb",
      "index": {
          "ddoc": "_design/date-index",
          "name": "date-index",
          "type": "json",
          "def": {
              "fields": [{"assetType": "asc"},{"originalCustomer.document":"asc"},{"transactionDate": "asc"}]
          }
      },
      "selector": {
          "$and": [
              {"assetType": {"$eq": "receivable"}},
              {"originalCustomer.document": {"$eq": "1"}},
              {"transactionDate": {"$gt": "1900-01-01"}}
          ]
      },
      "opts": {
          ...
      },
      "limit": 25,
      "skip": 0,
      "fields": "all_fields",
      "mrargs": {
          "include_docs": true,
          "view_type": "map",
          "reduce": false,
          "start_key": [
              "receivable",
              "1",
              "1900-01-01"
          ],
          "end_key": [
              "receivable",
              "1",
              "&lt;MAX&gt;"
          ],
          "direction": "fwd",
          "stable": false,
          "update": true,
          "conflicts": "undefined"
      }
  }
  </code></pre>
  
  <p>the same _find result is produced no matter if I use "asc" or "desc" on the index. I am expecting transactionDate "2019-01-02" to be the first on the list, given the descending ordering (I removed non related fields for brevity)</p>
  
  <pre class="lang-js prettyprint-override"><code>{
      "docs": [
          {
              "assetType": "receivable",
              "originalCustomer": {"document": "1"},
              "transactionDate": "2019-01-01"
          },
          {
              "assetType": "receivable",
              "originalCustomer": {"document": "1"},
              "transactionDate": "2019-01-01"
          },
          {
              "assetType": "receivable",
              "originalCustomer": {"document": "1"},
              "transactionDate": "2019-01-01"
          },
          {
              "assetType": "receivable",
              "originalCustomer": {"document": "1"},
              "transactionDate": "2019-01-02"
          },
          {
              "assetType": "receivable",
              "originalCustomer": {"document": "1"},
              "transactionDate": "2019-01-02"
          }
      ],
      "bookmark": "..."
  }
  </code></pre>