Return to Snippet

Revision: 8171
at September 5, 2008 11:22 by kowalskg


Updated Code
def sortedCount = badSnpsMap.keySet().toList()
sortedCount.sort{ badSnpsMap[it] }

println ""
println "Bad SNPS       count"
println "-------------------------------------------------"
sortedCount.reverse().each { probeSetId ->
        println "" << probeSetId << "\t\t" << badSnpsMap[probeSetId]
}


your: 2for: 1
"""
recipes: 1

Revision: 8170
at September 5, 2008 11:20 by kowalskg


Initial Code
def textCorpus =""" Look for the bare necessities The simple bare necessitiesForget about your worries and your strifeI mean the bare necessities Old Mother Nature's recipesThat bring the bare necessities of life"""
def words = textCorpus.tokenize()def wordFrequency = [:]words.each { word ->wordFrequency[word] = wordFrequency.get(word,0) + 1}def wordList = wordFrequency.keySet().toList()wordList.sort { wordFrequency[it] }
//#1 //|#2
def statistic = "\n"
wordList[-1..-6].each { word ->statistic += word.padLeft(12) + ': ' statistic += wordFrequency[word] + "\n"}assert statistic ==
"""
bare: 4
necessities: 4
the: 3
your: 2for: 1
"""
recipes: 1

Initial URL

                                

Initial Description

                                

Initial Title
Exmple of Sorting a Map

Initial Tags
groovy

Initial Language
Groovy