WoW:API sort: Difference between revisions

m
Changed < to &lt; because it was messing up the instructions
No edit summary
 
m (Changed < to &lt; because it was messing up the instructions)
Line 20: Line 20:


  > t = { 3,2,5,1,4 }
  > t = { 3,2,5,1,4 }
  > table.sort(t, function(a,b) return a<b end)
  > table.sort(t, function(a,b) return a&lt;b end)
  > = table.concat(t, ", ")
  > = table.concat(t, ", ")
  1, 2, 3, 4, 5         
  1, 2, 3, 4, 5         
Line 26: Line 26:
We can see if we reverse the comparison the sequence order is reversed.
We can see if we reverse the comparison the sequence order is reversed.


  > table.sort(t, function(a,b) return a>b end)
  > table.sort(t, function(a,b) return a&gt;b end)
  > = table.concat(t, ", ")
  > = table.concat(t, ", ")
  5, 4, 3, 2, 1
  5, 4, 3, 2, 1
Anonymous user