开发者

In Scala how do I apply a method to a variable before sorting a List on that variable?

开发者 https://www.devze.com 2023-03-20 17:09 出处:网络
For example suppose I have val sortedSignal =开发者_如何学C signal.sortBy(_.variable) And I wish to apply Math.abs to variable before sorting.What is the correct syntax for doing this?signal.sortBy

For example suppose I have

val sortedSignal =开发者_如何学C signal.sortBy(_.variable)

And I wish to apply Math.abs to variable before sorting. What is the correct syntax for doing this?


signal.sortBy(x=>Math.abs(x.variable))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号