The Turbine.Shell.GetCommands method returns a table with numeric keys representing an array of chat commands but the table has a key with a 0 value. Lua does not natively support 0 based arrays, for instance the Lua "ipairs" function processes key/value pairs starting with the key=1, not key=0. Additionally, the Lua sort function will not properly sort the table since the element with the key=0 does not get sorted.

Long story short, the GetCommands method should be returning a 1 based array for compatability with native Lua functions.

The work around is to add a new element with the value of the element with the key=0 then remove the with key value=0. ex:
Code:
cmds=Turbine.Shell.GetCommands()
if cmds~=nil and cmds[0]~=nil then
    table.insert(cmds,cmds[0])
    cmds[0]=nil
end
This will allow the native Lua functions such as ipairs and sort to work correctly with the cmds table.