How to sort characters in a string?

后端 未结 4 649
伪装坚强ぢ
伪装坚强ぢ 2020-12-25 14:55

I would like to sort the characters in a string.

E.g.

echo cba | sort-command
abc

Is there a command that will allow me to do this

4条回答
  •  既然无缘
    2020-12-25 15:46

    This is cheating (because it uses Perl), but works. :-P

    echo cba | perl -pe 'chomp; $_ = join "", sort split //'
    

提交回复
热议问题