Quantcast
Channel: Difference between Sort and SortBy - Mathematica Stack Exchange
Browsing all 5 articles
Browse latest View live

Answer by Michael E2 for Difference between Sort and SortBy

No one has mentioned the difference in performance:SeedRandom[0];data = RandomInteger[{-10000, 10000}, 10^5];sdata = Sort[data, Abs[#1] < Abs[#2] &]; // AccurateTimingsbdata = SortBy[data, Abs];...

View Article



Answer by Mr.Wizard for Difference between Sort and SortBy

I commented on this a bit here: What are the most common pitfalls awaiting new users?Since SortBy was introduced in Mathematica 6 it is preferred where applicable over Sort with a custom comparator....

View Article

Answer by MarcoB for Difference between Sort and SortBy

In general SortBy can do pretty much anything that Sort does; in some cases, possibly better or faster. You can find many comparisons on this site if you just search for both function names.I also...

View Article

Answer by nben for Difference between Sort and SortBy

SortBy is usually a more concise form of Sort, yes, but at times, you may have data that cannot be expressed, or cannot be expressed elegantly, using SortBy. For example, let's suppose that we want to...

View Article

Difference between Sort and SortBy

I was playing with Sort. All examples I have come across so far, i.e Sort[{1, -1, 3, -3, 2, 5}, Abs[#1]<Abs[#2]&] can expressed in a shorter fashion using SortBy SortBy[{1, -1, 3, -3, 2, 5},...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images