18
18. 各行を3コラム目の数値の降順にソート
各行を3コラム目の数値の逆順で整列せよ(注意: 各行の内容は変更せずに並び替えよ).確認にはsortコマンドを用いよ(この問題はコマンドで実行した時の結果と合わなくてもよい).
> Get-Content -Encoding UTF8 .\hightemp.txt | ConvertFrom-Csv -Header a,b,c,d -Delimite r `t | Sort-Object -Property c
18.hs
import System.Environment import System.IO.UTF8 as I8 import Data.List import Data.Ord main = do filename <- getArgs >>= return . head body <- I8.readFile filename I8.writeFile "18.out.txt" $ unlines $ nub . sortBy (\x y -> compare (f y) (f x)) $ lines body where f = flip (!!) 2 . words