Here is a question that I probably would have posed at in the past, but this time I tried it using ChatGPT

“In Mathematica, I can sort by the last element in a list using something like:

SortBy[{{1, 2, 3}, {2, 3, 1}, {3, 1, 2}}, Last]

How do I specify two sort keys, for example, sort using Last as the primary key, and First as a secondary key?”


Turns out that the answer was in the Mathematica help too, right in the synopsis:

but I didn’t see it, since I’d gone straight to the examples, and didn’t see anything there.

ChatGPT should have a fun mode like Grok.  The obvious answer should have made fun of my sample query, cut and pasted from the Mathematica SortBy help, perhaps:

“Your example sucks, since sorting by the primary key is sufficient.  If you really want to waste computing cycles, this is how to do what you asked…”

My real Sort was:

filtered3 = SortBy[Select[raw3, ( (# // Last) > 0 ) &], {Last, First}];

to produce the following table of router bushing offsets + bit size:

The sort for that table did require a primary and secondary key, and initially didn’t have a nice ordering.