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?


closed as off-topic by rhermans, Dr. belisarius, J. M. will be back soon Oct 14 '15 at 16:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – rhermans, Dr. belisarius, J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Take a look at SortBy. $\endgroup$ – Kuba Oct 14 '15 at 15:38
  • 1
    $\begingroup$ SortBy[m,Last] $\endgroup$ – IPoiler Oct 14 '15 at 15:39
  • $\begingroup$ Greetings! To make the most of Mma.SE please take the tour now. Help us to help you, write an excellent question. Edit if improvable, show due diligence, give brief context, include minimum working examples of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. $\endgroup$ – rhermans Oct 14 '15 at 15:41
  • $\begingroup$ Your question may be put on-hold as it seems to be off-topic, i.e it is easily found in the documentation and is unlikely to help any future visitors. Don't be discouraged by that cleaning-up policy. Your future good questions are welcome. Learn about common pitfalls here. $\endgroup$ – rhermans Oct 14 '15 at 15:47


m = {{a, 20}, {b, 10}, {c, 50}, {d, 5} , {e, 100}}


Reverse[SortBy[m, Last]]


SortBy[m, Minus@*Last]

or since Mathematica v12

{{e, 100}, {c, 50}, {a, 20}, {b, 10}, {d, 5}}

Where @* stands for Composition


Not the answer you're looking for? Browse other questions tagged or ask your own question.