No, but he sorts the strings as he should have done: Lexicographically
The relationship "200" < "30"is performed for the same reason as "Hello" < "World".
So, if you want Haskell to sort by a numerical value, you have to sort the actual numbers.
import Data.List
import Data.Function
sortNumeric = sortBy (compare `on` (read :: String -> Int))
sortNumeric ["1", "200", "234", "30"]
But: Why does your list full of βnumbersβ contain lines? Use instead [Int].
Dario source
share