summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Examples/example10.se
blob: 5037051f83e6f5665f7a3c12cd108c6eebc809d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
array data[4];
data[0] = 122;
data[1] = 3;
data[2] = -6;
data[4] = 55;

#this array is a mess, let's sort it!
def print_array(array)
{
	i = 0;
	while(i < len(array))
	{
		print(array[i], " ");
		i = i + 1;
	}
	print("\n");
}

print_array(data);

#as for now - it won't work
#I can't pass arrays to functions
#heh

def sort(data)
{
	i = 0;
	while(i < len(data))
	{
		j = 0;
		while(j < len(data) - 1)
		{
			if(data[j] > data[j + 1])
			{
				temp = data[j + 1];
				data[j + 1] = data[j];
				data[j] = data[j + 1];
			}
			j = j + 1;
		}
		i = i + 1;
	}
	return data;
}

sort(data);