Given a string, select all the numbers from it and sort them in ascending order. (Pascal ABC)

program zz1;
var s: string; // set a variable of string type
i, m, k, j, id_max, max: integer; // set variables of integer type
mas: array [1..255] of integer;
write (‘enter string’);
read (s); // enter a string from the keyboard
m: = 1;
for i: = 1 to length (s) do // organize a loop in which we iterate over all characters from the first to the last
if (s [i] = ‘0’) or (s [i] = ‘1’) or (s [i] = ‘2’) or (s [i] = ‘3’) or (s [i] = ‘4’) or (s [i] = ‘5’) or // check if the string character is a digit, then
(s [i] = ‘6’) or (s [i] = ‘7’) or (s [i] = ‘8’) or (s [i] = ‘9’)
then begin k: = strtoint (s [i]); mas [m]: = k; m: = m + 1; end; // translate a character to a number and write it to an array
// sort the array
j: = m-1;
while j> 1 do begin
max: = mas [1];
id_max: = 1;
for i: = 2 to j do
if mas [i]> max then begin
max: = mas [i];
id_max: = i
mas [id_max]: = mas [j];
mas [j]: = max;
j: = j – 1
for i: = 1 to m-1 do
write (mas [i], ”); // display the answer

One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.