Jump to content

Sorting algorithms/Gnome sort: Difference between revisions

m
Line 642:
do
from
i:= 2
i:= 2 -- In Eiffel the first element of an Array has index 1
j:= 3
until
Line 680:
make
 
feature
make
 
do
test := <<17, 2799, 32, 99-7, 1, -70, 325, 5-10>>
create gnome
io.put_string ("%NUnsorted: ")
across gnome.sort across (test) as ic ar loop io.put_string (ic ar.item.out + " %T") end
end
create test_result.make_empty
create sorter
test_result := sorter.sort (test)
io.put_string ("%NSorted: ")
across test_result as ic loop io.put_string (ic.item.out + " ") end
end
 
test: ARRAY[INTEGER]
test_resultgnome: ARRAYGNOME_SORT[INTEGER]
sorter: GNOME_SORT
 
 
end
 
</lang>
OUTPUT:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.