Forgot password?
 Create new account
View 127|Reply 1

关于SortBy的疑问

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-4-3 13:31:22 |Read mode
SortBy[{1,4,2,3},{EvenQ}]
{1,3,4,2}

SortBy[{1,4,2,3},EvenQ]
{1,3,2,4}

为何不一样?

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2023-4-5 16:28:01
好像是因为, SortBy会把结果用默认排序, 导致这里的{1,3,4,2}变成{1,3,2,4}
如果加{}, 表示依次用这组函数来排序, 规定了就是这组, 完了就不会再用默认排序
Wolfram Language Documentation
If some of the $f[e_i]$ are the same, then the canonical order of the corresponding $e_i$ is used.

手机版Mobile version|Leisure Math Forum

2025-4-20 22:20 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list