I have a list
m = {{a, 20}, {b, 10}, {c, 50}, {d, 5}, {e, 100}}
and I want to apply Sort on this in descending order on numbers only so that it looks like this
m = {{e, 100}, {c, 50}, {a, 20}, {b, 10}, {d, 5}}
How do I do that?
I have a list
m = {{a, 20}, {b, 10}, {c, 50}, {d, 5}, {e, 100}}
and I want to apply Sort on this in descending order on numbers only so that it looks like this
m = {{e, 100}, {c, 50}, {a, 20}, {b, 10}, {d, 5}}
How do I do that?
m = {{a, 20}, {b, 10}, {c, 50}, {d, 5} , {e, 100}}
Reverse[SortBy[m, Last]]
or
SortBy[m, Minus@*Last]
or since Mathematica v12
ReverseSortBy[Last][m]
{{e, 100}, {c, 50}, {a, 20}, {b, 10}, {d, 5}}
Where @* stands for Composition
SortBy. – Kuba Oct 14 '15 at 15:38SortBy[m,Last]– IPoiler Oct 14 '15 at 15:39