Let's say I have a list of lists like
data={{1,0},{2,1},{2,0},{3,0},{4,0},{5,1},{5,0},{6,0},{7,0},{8,1},{8,0},{9,3},{9,2},{9,1},{9,0},{10,0}};
with varying length and number of columns. It is sorted by a specific column (here by the first column) with applied descending values in another column (here the second column).
What I want to get is a list of lists with only the maximum value of the applied values in column 2 for every single value in column 1 like
result={{1,0},{2,1},{3,0},{4,0},{5,1},{6,0},{7,0},{8,1},{9,3},{10,0}}
With neither Extract[]
nor Select[]
nor Cases[]
did I had any success so far.
The code has to be Mathematica 4.3 compatible, because of why I can't use SelectCasesBy[]
nor MaxBy[]
..
Sorry if my question is a duplicate. I couldn't find a working solution on your site for my problem so far.
Thanks for your help!
((Merge[Rule @@@ data, Max] // Normal) /. Rule :> List ) == result
givesTrue
. $\endgroup$