Sorting a string alphabetically by line in Clojure(Script) -


suppose s string defined follows:

;; s b c 

is there clojure operation sort-alphabetically (that works in clojurescript) such (sort-alphabetically s) generates following string?

;; (sort-alphabetically s) => b c 

the following code snippet want:

(require '[clojure.string :as str])  (def s "c\nb\na")  (->> s   (str/split-lines) ; split string sequence of lines   (sort) ; sort sequence using natural order (for strings alphabetical order)   (str/join "\n")) ; join elements of sorted sequence using \n producing multiline string  ;; => "a\nb\nc" 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Apache Thrift Tutorial Error -