Suppose if I have following list
{
{10,b,30},
{100,a,40},
{1000,b,10},
{1000,b,70},
{100,b,20},
{10,b,70}
}
How to find rows that have max value in 3rd column, in this case
{
{1000,b,70},
{10,b,70}
}
|
Suppose if I have following list
How to find rows that have max value in 3rd column, in this case
|
||||
|
With:
Perhaps most directly:
More approaches:
Of these |
|||||||||||||
|
|
This works:
|
|||||||
|
|
You can use
|
|||
|
|
|
Here's a method with a stable sort involving two of my favorite functions,
The way In this case, I use the third element of the tuple as the As a curious note, initially I tried attaching the test to the |
|||
|
|
|
Update: Here's a nice and short one (if not fast):
You got many nice solutions. I'd like to add one more, which is less general, and only works when there's a singe maximum, but illustrates nicely how Analogously to
Then with your data,
Again, this will give you a single result only, not two as in your example. |
||||
Pickwould probably be fastest (@J.M solution) if the list is long. – Mike Honeychurch Jan 28 '12 at 23:23