new format convention
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
fun copy(L)
|
fun copy(L) {
|
||||||
{
|
|
||||||
L2 = [];
|
L2 = [];
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while i < count(L):
|
while i < count(L): {
|
||||||
{
|
|
||||||
L2[i] = L[i];
|
L2[i] = L[i];
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
@@ -13,22 +12,18 @@ fun copy(L)
|
|||||||
return L2;
|
return L2;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bubble_sort(L, less)
|
fun bubble_sort(L, less) {
|
||||||
{
|
|
||||||
if less == none:
|
if less == none:
|
||||||
fun less(a, b) return a < b;
|
fun less(a, b) return a < b;
|
||||||
|
|
||||||
L = copy(L);
|
L = copy(L);
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
swapped = false;
|
swapped = false;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while i < count(L)-1 and not swapped:
|
while i < count(L)-1 and not swapped: {
|
||||||
{
|
if less(L[i+1], L[i]): {
|
||||||
if less(L[i+1], L[i]):
|
|
||||||
{
|
|
||||||
swapped = true;
|
swapped = true;
|
||||||
tmp = L[i+1];
|
tmp = L[i+1];
|
||||||
L[i+1] = L[i];
|
L[i+1] = L[i];
|
||||||
@@ -36,8 +31,7 @@ fun bubble_sort(L, less)
|
|||||||
}
|
}
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
} while swapped;
|
||||||
while swapped;
|
|
||||||
|
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user