sorting data using array in ksh

plz help me..........i have a ksh script that sorts data in ascending order.
the 1st half is correct,but for the line no 31 its showing problem

 1  \#!/bin/ksh
 2  
 3  
 4  
 5  echo "Enter the array length"
 6  read num
 7  
 8  
 9  echo "enter the elements"
10  
11  i=0
12  
13  while \(\( i < num \)\)
14  do
15  read element1
[i]16  i=\`expr $i \+ 1\`
17  done
18  
19  i=0
20  echo "The elements are"
21  echo $\{element1[*]\}
22   
23  i=0
24  temp=0
25  while \(\( i < num \)\)
26  do
27  
28  j=\`expr $i \+ 1\`
29  while \(\( j < num \)\)
30  do
31  if \(\( element1 [i]> element1[j] \)\)
32  then
33  temp=$element1
[i]34  element1[i]=$element1[j]
35  element1[j]=$temp
36  else
37  echo " "
38  fi
39  j=\`expr $j \+ 1\` 
40  done
41  i=\`expr $i \+ 1\`
42  done
43  
44  echo "The element in ascending order are "
45  echo $\{element1[*]\} 

----------------------------------------------------------------------

Hi,

The problem in the above code is in accessing the array elements.

The array elements should be accessed as ${array[num]}

Use the below code in your script,

if (( ${element1[i]} > ${element1[j]} ))
then
temp=${element1[i]}
element1[i]=${element1[j]}

Regards,
Chella

thanks a lot dear.got it

very much thanks to u.
hey can u also tell me how to blink a text in a file and contnue with the rest of the program.
actually it only blinks and i cannot do the rest as i should wait for the blinking to stop

can u show me a simple example in ksh

Ordinarily, yes, you would need to quote subscripted variables within braces "{ }" to protect the square brackets "[ ]" from the shell when accessing them. (You don't need to do this when setting them.) This should not be necessary inside the evaluation of double-parenthesis "(( ))". So the problem is not at line 31, but at 33, 34, and 35, using the syntax as suggested above. It just shouldn't be needed in the "if" clause.

You can blink text with "tput" if your terminal type supports blinking text. See the man page of tput for the correct options to use (i.e., I can't remember!)

thanks dear for ur suggestion !

i have tried that but not able to blink the text simultaneously and proceed with the prorgam