title: Corona table.sort()
body: <pre><code>local tile = {"C", "O", "L", "I", "N", "F", "A", "R", "R", "E", "L", "L"}       
  table.sort(tile, function(a,b) return ( math.random(1,2) &lt;2) end)
  print ( 'table: '..table.concat( tile, ', '))
  </code></pre>
  
  <p>I am randomizing the order of the table, which seems to work fine, but every 2nd time I run the program I get this error : <code>invalid order function for sorting</code>. Any suggestions as to what is happening?</p>
  
  <p>I have found the solution to this.
  <a href="http://developer.coronalabs.com/code/shufflerandomize-tables" rel="nofollow">http://developer.coronalabs.com/code/shufflerandomize-tables</a>
  This will shuffle the contents of your table without any of the problems of the method above.</p>