Probably this is too trivial question for this forum but for some reason I am not getting it on my Mathematica 7 so far. I have a list
list = {{b, 3.04},{d,3},{a,3.10},{c,3}}
I want to sort it for the second element and eliminate those elements for which the second element has the same value. The first element doesn't matter much. In short, the answer should be
{{d,3},{b,3.04},{a,3.10}}
I used
SortBy[list,#[[2]] &]
to sort the list
with respect to the second element. I can also do something similar for eliminating the elements for which the second element has the same value. But is there any more efficient way? It is something like Union but only for the second element if you know what I mean?
Comments
Post a Comment