Groovy web console

subscribe to the feed Subscribe
to this
site

Emman

Published 1 month ago by Emman with tags data
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
List<One> datas = []

['1100110022' : 12,'1100112222': 12,'12330022': 34,'987648293':543,'55443677':543,'998433522':1].each { String key, Integer value ->
 datas.add(new One(probability: value, hsCode: key))
}

Integer one = datas.max { it.probability }.probability
datas.findAll { it.probability == one }


class One { 
    String hsCode
    Integer probability

    @Override
    String toString() {
        return " HSCODE: "+hsCode+"\t PROBABILITY: "+ probability
    }
}