INPUT "vvedite frazu ", b$
DIM a$(100)
b$ = " " + b$
FOR i = 1 TO LEN(b$)
IF MID$(b$, i, 1) = " " THEN k = k + 1 ELSE a$(k) = a$(k) + MID$(b$, i, 1)
NEXT
FOR i = 1 TO k
FOR j = 2 TO k
IF LEN(a$(j)) > LEN(a$(j - 1)) THEN SWAP a$(j), a$(j - 1)
NEXT
NEXT
FOR i = 1 TO k
c$ = c$ + a$(i) + " "
NEXT
PRINT c$
Тестирование выполнено в программе QB64 ( Скачать )