ゲンゾウさんのページのgroovyでどう書く.orgに触発されて書いてみました。
boolean firstLine = true def lines = [] new File("test.csv").eachLine { e = it.split("\t") if (firstLine) { println([e[0],e[2],e[1],e[3]].join("\t")) firstLine = false } else { lines.push(e) } } lines.sort{it[0].toInteger()}.each{ println([it[0],it[2],it[1],it[3].toInteger()+1].join("\t")) }
sort{it[0].toInteger()}とかにいつも感動を覚える私。比較コードすら書かなくていいとは。ちなみに例えば第二キーを指定する場合、sort{[it[0].toInteger(),it[3].toInteger()]}(この機能は勘違い。参考)
とかでOK。