PharoJS
PharoJS copied to clipboard
sort: [:a :b | ] apparently a number is expected as block value instead of a boolean.
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 ] ]
By default PharoJS does not include sort: method. Instead, it is the one provided by Javascript that is used. Hence the strange behavior.
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