DanMonroe
unread,Apr 21, 2009, 6:00:28 PM4/21/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Groovy Sydney
HI All,
Hopefully this is an easy question.
Given an unsorted list of numbers, I need to "drop" or disregard N
number of the highest numbers. Then I need to print the list in
original order and show which numbers were dropped.
for example, given:
def myList = [ 5, 2, 7, 9, 7, 3, 1 ]
def highNumbersToDrop = 2
// I need to...
myList.each() { thisItem ->
println thisItem
}
// having a result of something like:
5
2
7 - dropped
9 - dropped
7
3
1
My question is how to keep track of which numbers were "dropped" so
that when I display the list, I can add the " - dropped" text.
Thanks in advance,
Dan