title: How to sort DynamoDB Hashkey in ascending order in Android
body: <p>I'm working on an Android application where I'm creating a DynamoDB table with a "Number" Hashkey. </p>
  
  <pre><code>public static void createTable() {
  
      Log.d(TAG, "Create table called");
  
      AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
              .ddb();
  
      KeySchemaElement kse = new KeySchemaElement().withAttributeName(
              "Tid").withKeyType(KeyType.HASH);
      AttributeDefinition ad = new AttributeDefinition().withAttributeName(
              "Tid").withAttributeType(ScalarAttributeType.N);
  
      ProvisionedThroughput pt = new ProvisionedThroughput()
              .withReadCapacityUnits(10l).withWriteCapacityUnits(5l);
  
      CreateTableRequest request = new CreateTableRequest()
              .withTableName(Constants.TEST_TABLE_NAME)
              .withKeySchema(kse).withAttributeDefinitions(ad)                               
              .withProvisionedThroughput(pt);
  
      try {
          Log.d(TAG, "Sending Create table request");
          ddb.createTable(request);
          Log.d(TAG, "Create request response successfully recieved");
      } catch (AmazonServiceException ex) {
          Log.e(TAG, "Error sending create table request", ex);
          UserPreferenceDemoActivity.clientManager
                  .wipeCredentialsOnAuthError(ex);
      }
      insertUsers();
  }
  </code></pre>
  
  <p>I'm then calling the insertUsers() method in the end, where I'm adding three Key values (800,815,830) into the created table:</p>
  
  <pre><code> public static void insertUsers() {
      AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
              .ddb();
      DynamoDBMapper mapper = new DynamoDBMapper(ddb);
  
      try {
          for (int i = 1; i &lt;= 3; i++) {
              UserPreference userPreference = new UserPreference();
  
              if (i == 1)
              {
               userPreference.setTid(800);                 
              }
              else if (i == 2)
              {
                  userPreference.setTid(815); 
              }
              else
              {
                  userPreference.setTid(830);                     
              }
  
              Log.d(TAG, "Inserting Tid and Dage");
              mapper.save(userPreference);
              Log.d(TAG, "Tid and Dage inserted");
          }
      } catch (AmazonServiceException ex) {
          Log.e(TAG, "Error inserting users");
          UserPreferenceDemoActivity.clientManager
                  .wipeCredentialsOnAuthError(ex);
      }
  } 
  </code></pre>
  
  <p>But the ordering in AWS DynamoDB Service is:</p>
  
  <p><img src="https://i.stack.imgur.com/2lHOM.png" alt="enter image description here"> </p>
  
  <p>How do I sort the table in ascending order, so I can obtain the ordering like : 800,815,830</p>