Groovy noob here.
I have this map
signedMap = [[k:a, v:1], [k:b, v:-2], [k:c, v:3], [k:d, v:-4]]
I need to find the maximum absolute value, in this example -4
This my current code
def absMap = []
signedMap.each {
absMap.add([k:it.k, absv:it.v.abs()])
}
def sortedAbs = absMap.sort{it.absv}
def maxAbs = sortedAbs.last().absv
Is there a more elegant way to do this?
Thanks!