Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,41 @@
import extensions;
import system'routines;
extension op
{
gnomeSort()
{
var list := self.clone();
int i := 1;
int j := 2;
while (i < list.Length)
{
if (list[i-1]<=list[i])
{
i := j;
j += 1
}
else
{
list.exchange(i-1,i);
i -= 1;
if (i==0)
{
i := 1;
j := 2
}
}
};
^ list
}
}
public program()
{
var list := new int[]{3, 9, 4, 6, 8, 1, 7, 2, 5};
console.printLine("before:", list.asEnumerable());
console.printLine("after :", list.gnomeSort().asEnumerable())
}