Difficulty: | Medium |
Topics: | sorting |
Write a function that splits a sentence up into a sorted list of words. Capitalization should not affect sort order and punctuation should be ignored.
(= (__ "Have a nice day.") ["a" "day" "Have" "nice"])
(= (__ "Clojure is a fun language!") ["a" "Clojure" "fun" "is" "language"])
(= (__ "Fools fall for foolish follies.") ["fall" "follies" "foolish" "Fools" "for"])
相对简单,因为没有特殊限制: 长度:69
(fn [x]
(sort #(compare (.toLowerCase %)(.toLowerCase %2)) (re-seq #"\w+"x)))