How can change alfabetic order (REM: CTX DATA TABLE DEMO PROGRAM) ,read from file

When I change your demo:I can't use order to change in alfabetic order
first column,second column,....... (order button)
first column:cursor is on position Surname press order button
when column highligthed.
How can new data files be send to overwrite old file.(Book1.csv)
///////////////////////////////////////////////////////
click button order I get this error.
//////////////////////////////////////////////////////

Exception 2001 caused at line 5258 in -ctxlib split_data; entering immediate mode.
Type "continue" or click on default output window to exit immediate mode.

Subscript out of bounds(2001) 5258 in ctxlib split_data,2097 in ct_table dataorder,94
in main program

How can the program be changed.
/////////////////////////////////////////////////////
? easy way to read table in a matrix.(from below)
/////////////////////////////////////////////////////

REM: CTX DATA TABLE DEMO PROGRAM
option nolet
! change these library paths to suit
REM: change the pathnames to suit
LIBRARY "D:\prog\TB Gold\TBLibs\ctx7\CTX7.trc"
LIBRARY "D:\prog\TB Gold\TBLibs\ctx7\truectrl.trc"

DECLARE PUBLIC CTbx

DIM pw(6)
!DIM array$(0:25,7)

CALL TC_init
CALL TC_setunitstopixels

REM: how big is the screen
CALL TC_getscreensize(lscr,rscr,bscr,tscr)
LET midxscr=int((lscr+rscr)/2) ! mid x axis
LET midyscr=int((tscr+bscr)/2) ! mid y axis

REM: create a working window
CALL TC_win_create(progwin,"TITLE|CLOSE",midxscr-300,midxscr+320,midyscr+210,midyscr-190)

CALL TC_pushbtn_create(pw(6),"Exit Demo",250,370,380,360)
CALL TC_pushbtn_create(pw(1),"Remove",160,240,380,360)
CALL TC_pushbtn_create(pw(2),"Insert",70,150,380,360)
CALL TC_pushbtn_create(pw(3),"Order",380,460,380,360)
CALL TC_pushbtn_create(pw(4),"Format",470,550,380,360)

CALL TC_show(progwin)
CALL TC_win_switch(progwin)

REM: set title for window
CALL TC_Win_SetTitle (progwin,"Demo Data Table")
REM: set background color gray
CALL TC_win_setbrush(progwin,7,7,"SOLID")
CLEAR
CALL TC_show(pw(6))
s$="D:\prog\TB Gold\Book1.csv"
LET option$="VSCROLL|HSCROLL|RECESS|VRULE|HRULE"
CALL CT_Table_create(ct16,option$,50,550,340,20)
CALL CT_Table_setcolor(ct16,-1,20,4,0,22,21)
CALL CT_setfont(ct16,"Arial",8,"plain")
CALL CT_Table_ReadFile(ct16,s$,"","")
CALL CT_show(ct16)

REM: create event loop

DO

CALL CT_event(event$,window,x1,x2,id,type)
IF event$="KEYPRESS" and x1=335 then
LET CTbx=1
END IF

IF event$ = "HIDE" then ! close window button has been pressed
IF window=0 or window=progwin then
EXIT DO
END IF

ELSEIF event$="KEYPRESS" then
IF x1=27 then ! ESC key
EXIT DO
END IF

ELSEIF event$="SINGLE" then

IF type=7 then ! must be data table
REM: remember id
LET tableID=id
END IF

ELSEIF event$="CONTROL DESELECTED" then

IF x2=pw(6) then ! push button has been pressed
EXIT DO
ELSEIF x2=pw(1) then ! remove
CALL CT_Table_RemoveData(tableid,0,datarow$)

ELSEIF x2=pw(2) then ! insert
CALL CT_Table_InsertData(tableid,0,datarow$)

ELSEIF x2=pw(3) then ! order strings alphabetically
REM: method 1=alphabetic A-Z
REM: method 2=reverse alph Z-A
REM: method 3=ascii & numeric ascending
REM: method 4=reverse ascii & numeric descending

CALL CT_Table_DataOrder(tableid,0,1)

ELSEIF x2=pw(4) then ! format numbers
CALL CT_Table_DataFormat(tableid,0,"#########")

END IF
END IF

LET x1=0
LET x2=0

LOOP

CALL TC_cleanup

END