c# - simple way to sort a list based on max value of a property -
i have list joining tables, list has low range , high range values, goal select row has maximum lowrange value, in example below,
i select rate 15.5 since has highest lowrange val
rate lowrange highrange --------------------------------------- 12.5 300000 0 15.5 1500000 300001 17.5 null 1500001
any ideas how can achieve using linq, c# of help
@cuongle has simplest answer.
there nice extension linq (originally written jon skeet part of morelinq, or see here) called maxby()
let this:
var max = list.maxby(item => item.lowrange);
this lot more efficient because o(n), whereas orderbydecending()
o(n*log(n))
Comments
Post a Comment