3 points | by xeouz 8 hours ago ago
1 comments
OP here! If anyone is curious about the syntax without opening the demo, here is an implementation of insertion sort:
extern puti(n: int);
func sort(arr: int[5]) {
let i=0; let key=0; let j=0; for(i=0; i<5; ++i) { key = arr[i]; j = i-1; while(j>=0) { if(arr[j] < key) { break; } arr[j + 1] = arr[j]; j-=1; } arr[j + 1] = key; }
let arr=[61,86,53,19,61];
sort(arr);
for(let i=0; i<5; ++i) {
puti(arr[i]); }
OP here! If anyone is curious about the syntax without opening the demo, here is an implementation of insertion sort:
extern puti(n: int);
func sort(arr: int[5]) {
}let arr=[61,86,53,19,61];
sort(arr);
for(let i=0; i<5; ++i) {