Cортировка была реализована методом пузырька
var i, n, j, b, k: integer;
M, A: array [1..20] of integer;
begin
n := 1;
for i := 1 to 20 do
begin
read (M[i]);
if M[i] > 5 then
begin
A[n] := M[i];
inc(n);
end;
end;
for j := 1 to n - 1 do
for i := 1 to n - j do
if A[i] > A[i + 1] then
begin
b := A[i];
A[i] := A[i + 1];
A[i + 1] := b;
end;
write('Начальный массив: ');
for i := 1 to 20 do
write (M[i], ' ');
writeln;
write('Новый массив: ');
for i := 1 to n do
write (A[i], ' ');
end.