PharoJS icon indicating copy to clipboard operation
PharoJS copied to clipboard

sort: [:a :b | ] apparently a number is expected as block value instead of a boolean.

Open bouraqadi opened this issue 6 years ago • 2 comments

Issue raised by Ivo on Discord.

To get the correct behavior Ivo had to do write the following code

items sort: [ :a :b |  (Date new: a start dateTime) < (Date new: b start dateTime) ifTrue: [ -1 ] ifFalse: [ 1 ] ]

bouraqadi avatar Sep 14 '19 07:09 bouraqadi

By default PharoJS does not include sort: method. Instead, it is the one provided by Javascript that is used. Hence the strange behavior.

bouraqadi avatar Sep 14 '19 08:09 bouraqadi

I think we should define a sort: method with Smalltalk semantics. If someone wants Javascript semantics, they can use js_sort:

I don't usually advocate using the js_ prefix because, among other things, you lose Smalltalk portability

dvmason avatar Apr 19 '20 17:04 dvmason