Forgot password?
 Register account
View 248|Reply 1

关于SortBy的疑问

[Copy link]

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

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

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

为何不一样?

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

 Author| hbghlyj Posted 2023-4-5 16:28
好像是因为, 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|Discuz Math Forum

2025-6-5 01:42 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit