One can specify the second argument of SortBy
not to sub-sort ties, i.e. cases that have identical values according to the main sorting function. SortBy[list, {First}]
ensures that sublists are sorted by the first (real) element, and ties are not resolved but left in the order they appear in the original list.
list = {{.1, {0, 1, 2}}, {.4, {1}}, {.1, {0, 1}}, {.7, {0}}};
Column /@ {list, SortBy[list, First], SortBy[list, {First}], SortBy[list, {}], SortBy[list, Identity]}
How can I specify a second argument for SortBy
that leaves list
as is, without actually sorting it? Clearly, {}
or Identity
, {Identity}
, etc. do not achieve this.
While I strongly believe this cannot be done, as SortBy
is a function specifically designed to sort, I nevertheless post this as there may be some undocumented way to do it simply.