title: dynamodb query keyConditionExpression sort by sortkey
body: <p>I am trying to sort my dynamo db results by the sort and key and also get a range of values based on the sort key and i keep getting invalid key condition expression error. basically im trying to get a range of values based on my sort key and also sort them.</p>
  <p>example of saved db item:</p>
  <pre><code>{
  id: ORDER_287d6df3-bd9f-472d-87ef-ee9b810b5874
  issued_at: 2021-05-07T15:09:11.894Z
  base_cur: NGN
  orderRate(GSI): SELL#500
  quantity: 300
  quantityRemaining: 300
  quantityRemoved: 0
  quote_cur: GBP
  rate: 500
  side: SELL
  ticker(GSI): GBP#NGN
  }
  </code></pre>
  <p>what i have tried:</p>
  <pre><code>const params = {
          TableName: process.env.ORDERS_TABLE_NAME,
          IndexName: 'ticker_orderRate',
          KeyConditionExpression: `ticker = :ticker and orderRate between :maxRate and :baseRate`,
          ExpressionAttributeValues: {
              ':ticker': `${quote_cur}#${base_cur}`,
              ':maxRate': `${side === 'BUY' ? 'SELL' : 'BUY'}#${rate}`,
              ':baseRate': `${side === 'BUY' ? 'SELL' : 'BUY'}#0.00`,
          }
      };
  </code></pre>
  <p>the rate is a number that comes from an SNS topic.</p>
  <p>Error message:</p>
  <pre><code>ERROR: ValidationException: Invalid KeyConditionExpression: The BETWEEN operator requires upper bound to be greater than or equal to lower bound; lower bound operand: AttributeValue: {S:BUY#620}, upper bound operand: AttributeValue: {S:BUY#0.00}
  </code></pre>
  <p>is there a way i can transform the rate and the base rate to numbers while querying the database? and also how do i sort by ascending order?
  Thanks for the help</p>