The sort command lets me put lines in alphabetical order and remove duplicate lines. I need something similar that can sort the words on a single line, put them
sort
Use tr to change spaces to new lines, then sort, and finally change new lines back to spaces.
tr
echo $(tr ' ' '\n' <<< "zebra ant spider spider ant zebra ant" | sort -u)