repo.or.cz
/
lua.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Imported from ../lua-1.1.tar.gz.
[lua.git]
/
test
/
teste.lua
blob
467ce1225bf8baf4daf6bba80eaf959a8016d4cf
1
function
sort
(
a
,
n
)
-- selection sort
2
local
i
=
1
3
while
i
<=
n
do
4
local
m
,
j
=
i
,
i
+
1
5
while
j
<=
n
do
6
if
a
[
j
]<
a
[
m
]
then
m
=
j
end
7
j
=
j
+
1
8
end
9
a
[
i
],
a
[
m
]=
a
[
m
],
a
[
i
]
-- swap a[i] and a[m]
10
i
=
i
+
1
11
end
12
end
13
14
15
v
=
@
(
5000
)
16
17
i
=
1
18
while
i
<=
5000
do
v
[
i
] =
5000
-
i i
=
i
+
1
end
19
20
sort
(
v
,
5000
)
21
22
print
(
"v512 = "
..
v
[
512
])