Hi Levente,<br>
<br>
<i>> It's not clear to me what you mean by "invert the order of a compare sort block.".<br>
</i><br>
You mentioned that it is possible to pass a BlockClosure instead of a sorting function into something like #sorted:. However, BlockClosures are not fully polymorphic to SortFunctions, so for example, you cannot send #, or #reversed to them.<br>
<br>
Regarding the chaining you mentioned, this is indeed not supported, unfortunately. Please see Collections-ct.955 for a second attempt. :-)<br>
<br>
Best,<br>
Christoph<br>
<br>
<font color="#808080">---<br>
</font><i><font color="#808080">Sent from </font></i><i><u><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><font color="#808080">Squeak Inbox Talk</font></a></u></i><br>
<br>
On 2021-06-12T21:52:27+02:00, leves@caesar.elte.hu wrote:<br>
<br>
> On Thu, 10 Jun 2021, christoph.thiede at student.hpi.uni-potsdam.de wrote:<br>
> <br>
> > Hi Levente,<br>
> ><br>
> >> #sort: and #sorted: expect an argument which responds to #value:value: with a boolean, so both of those examples work if you don't send #asCompareSortFunction to the block.<br>
> >><br>
> >> However, #asCompareSortFunction may be useful if you want to create chained sort functions. I'm not sure about the name though.<br>
> ><br>
> > Ouch! I did not see the wood for the trees. :-) But yes, if you would like to, for example, invert the order of a compare sort block, the protocols would not match ... So I guess this would still be relevant.<br>
> <br>
> It's not clear to me what you mean by "invert the order of a compare sort <br>
> block.".<br>
> However, I see one problem with the implementation. It evaluates the block <br>
> but lies about equality. It only returns -1 or 1, never 0. Which means, <br>
> chaining is impossible.<br>
> Here's an example:<br>
> <br>
> #((1 a) (1 b)) sorted: [ :a | a first ] ascending, [ :a | a second ] descending<br>
> "==> #(#(1 #b) #(1 #a)) which is fine"<br>
> <br>
> but<br>
> <br>
> #((1 a) (1 b)) sorted: [ :a :b | a first <= b first ] asCompareSortFunction, [ :a | a second ] descending.<br>
> "==> #(#(1 #a) #(1 #b)) which is not what I would expect"<br>
> <br>
> <br>
> Levente<br>
> <br>