CodeEvalのSimpleSortingの解法に関する質問です。
https://www.codeeval.com/open_challenges/91/
以下のコードを実行すると、Float型のソートがうまく行きません。
(-10.000, -1.000, -2.000) -> (-1.000, -2.000, -10.000)
なぜなのか、ヒントを教えてください。
(ns simple-sorting.core
(:use [clojure.string :only [split join]])
(:gen-class))
(defn splt-num [s]
(split s #" "))
(defn str->num [coll]
(map read-string coll))
(defn num->float3 [coll]
(vec (map #(format "%.3f" %1) coll)))
(with-open [rdr (clojure.java.io/reader (first *command-line-args*))]
(doseq [line (remove empty? (line-seq rdr))]
(def nums (splt-num line))
(def nss (str->num nums))
(def f3 (num->float3 nss))
(println (join " " (sort f3)))))