Sorting algorithms/Gnome sort: Difference between revisions

Content added Content deleted
Line 637:
 
sort (ar: ARRAY [G]): ARRAY [G]
-- sortSort array arin withascending gnome sortorder.
require
array_not_void: ar /= VOID
Line 667:
end
ensure
same_lengthSame_length: ar.count = Result.count
Result_is_sorted: is_sorted (Result)
end
Line 676:
--- Is 'ar' sorted in ascending order?
require
ar_not_empty: ar.is_empty = FALSEFalse
local
i: INTEGER
do
Result := TRUETrue
from
i := ar.lower
Line 687:
loop
if ar [i] > ar [i + 1] then
RESULTResult := FALSEFalse
end
i := i + 1