Skip to content

Instantly share code, notes, and snippets.

@tyama
Created October 20, 2008 06:27
Show Gist options
  • Save tyama/18027 to your computer and use it in GitHub Desktop.
Save tyama/18027 to your computer and use it in GitHub Desktop.
def clo = {f,c,skey->
def r=[]
new File(f).text.trim().splitEachLine(/\t/){ r<<c(it) }
return [
r.first().join("\t"),
r.tail().sort{it[skey]}*.join("\t").join("\n")
].join("\n")
}
println clo("data.csv",{[it[0],it[2],it[1],(it[3].isNumber())? it[3].toInteger()+1:it[3]]},0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment