In Common Lisp, strings are sequences, and sort works with any type of sequence, so it will do the trick.
Here is an example:
(let ((the-string (copy-seq "this is the string"))) (sort the-string #'char-lessp)) ;; => " eghhiiinrsssttt"
And here is the Hyperspec entry for sort and stable-sort . Just select your predicate (second sort argument) to get your desired sort order.
Note that I used copy-seq in the example because sort is destructive - it changed the string in place.
source share