If you're going to sort on classes, you'll probably want to create the classes table in alphabetical order because TableData is storing the classes key (1, 2, 3 etc.) not the actual class name.
Code:
local classes = { "DH", "DK", "Druid", "Hunter", "Mage", "Monk", "Paladin", "Priest", "Rogue", "Shaman", "Warlock", "Warrior" } -- Sorted to use keys[i] insted of full class name in the table