es2015/object-store/query-engine.js
function canOptimizeSorting(expectedSortingDirection, order) {
  for (let orderingFieldPath of order) {
    if ((orderingFieldPath.charAt(0) === "!") !== expectedSortingDirection) {
      return false
    }
  }
  
  return true
}
function canOptimizeSorting(expectedSortingDirection, order) {
  for (let orderingFieldPath of order) {
    if ((orderingFieldPath.charAt(0) === "!") !== expectedSortingDirection) {
      return false
    }
  }
  
  return true
}
Determines whether the sorting of the query result can be done through an
index (provided such index exists) or the natural order of the records in
the object store.

@param {boolean} expectedSortingDirection The sorting direction that is
expected from all sort-by fields so that the sorting can be
optimized. {@code true} represents descending order, {@code false}
represents ascending order.
@param {string[]} order Ordering field paths specifying how the records
should be sorted.
@return {boolean} {@code true} if the sorting can be optimized, if an
appropriate index exists or the natural order of the records in the
object store matches the order denoted by the field paths.