Stable Sorting, ie, Minimally-Disruptive Sorting

后端 未结 4 1133
囚心锁ツ
囚心锁ツ 2021-02-02 14:29

Suppose I have a list of things (numbers, to keep things simple here) and I have a function I want to use to sort them by, using SortBy. For example, the following sorts a list

4条回答
  •  温柔的废话
    2021-02-02 15:05

    Does GatherBy do what you want?

    Flatten[GatherBy[{301, 201, 502, 501, 101}, Mod[#, 10] &]]
    

提交回复
热议问题