Posted By

dima767 on 06/28/07


Tagged

tags web20 groovy cloud tag


Versions (?)

Simple tag cloud


 / Published in: Groovy
 

  1. static final popularityMap = [(0..9):'notPopular',(10..29):'notVeryPopular',(30..49):'popular',(50..100):'veryPopular',(101..Integer.MAX_VALUE):'ultraPopular']
  2.  
  3. tags = []
  4. 9.times { tags << 'tag1' }
  5. 12.times { tags << 'tag2' }
  6. 44.times { tags << 'tag3' }
  7. 50.times { tags << 'tag4' }
  8. 233.times { tags << 'tag5' }
  9.  
  10. tagsByPopularity = [:]
  11. tags.sort().each { item ->
  12. if(!tagsByPopularity[item]) {
  13. count = tags.count(item)
  14. popularityMap.each { k,v ->
  15. tagsByPopularity[item] = v
  16. }
  17. }
  18. }
  19.  
  20. println tagsByPopularity

Report this snippet  

You need to login to post a comment.