2

怎么会这样

⌽(⍒'Hello')

1 2 4 3 5

什么时候

⍋'Hello'

1 2 3 4 5

?

我是 APL 的新手,偶然发现了它。我只是想知道为什么第二个 l 出现在第一个之前。

4

2 回答 2

3
于 2012-02-17T07:23:35.447 回答
0

The grade up ⍋ and grade down ⍒ primitives preserve the order of equal elements. As others have said, there must be a rule for equal arguments. But this rule has the virtue that it allows multi-key sorts. That is, if you have an array with several associated keys, by sorting on each key from least significant to most significant, you obtain a result sorted by the most significant key, with equals sorted by the 2nd mot significant, items equal on the 1st two sorted by the 3rd, and so on. For this to work the index vector must be captured and used to update all keys and the data to keep them in sync. Or they could be stored in a nested structure, in which case they would automatically be kept in proper relative order.

于 2016-10-10T18:15:44.290 回答