SortBy

SortBy[list, f]
sorts the elements of list in the order defined by applying f to each of them.

DetailsDetails

  • SortBy[{e1, e2, e3, ...}, f] sorts the so that the lie in canonical order.
  • If some of the are the same, then the canonical order of the corresponding is used.
  • SortBy[list, {f1, f2, ...}] breaks ties by successively using the values obtained from the .
  • SortBy uses the canonical ordering described in the notes for Sort.
  • SortBy can be used on expressions with any head, not only List.
New in 6 | Last modified in 7
New to Mathematica? Find your learning path »
Have a question? Ask support »