title: Sorting a Lua table by key
body: <p>I have gone through many questions and Google results but couldn't find the solution.</p>
  
  <p>I am trying to sort a table using <code>table.sort</code> function in Lua but I can't figure out how to use it.</p>
  
  <p>I have a table that has keys as random numeric values. I want to sort them in ascending order. I have gone through the Lua wiki page also but <code>table.sort</code> only works with the table values.</p>
  
  <pre><code>t = { [223]="asd", [23]="fgh", [543]="hjk", [7]="qwe" }
  </code></pre>
  
  <p>I want it like: </p>
  
  <pre><code>t = { [7]="qwe", [23]="fgh", [223]="asd", [543]="hjk" }
  </code></pre>