write a code to sort string
16 views (last 30 days)
Show older comments
how to I write a code for this problem:
Write a program that accepts a string from a user with the input function, chops that string into a series of tokens, sorts the tokens into ascending order, and prints them out.
this is what I wrote so far I dont know what to do
%Input a user string
str=input('Enter string:','s');
[token,remain]=strtok(str,',')
Answers (1)
ANKUR KUMAR
on 17 Mar 2021
str=input('Enter string:','s');
strsplit(str,',')
On which basis you wish to sort strings? Is it alphabatically, or based on the length ?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!