grumpyhome / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
420 stars 18 forks source link

Check stability of `sorted()` code #120

Open alanjds opened 6 years ago

alanjds commented 6 years ago

As pointed on https://github.com/grumpyhome/grumpy/issues/82#issuecomment-433899574, the sorting of lists are not respecting stability or comparison of types:

$ python -c 'print sorted([1,1.0,2,2.0], reverse=True)'
[2, 2.0, 1, 1.0]
$ grumpy -c 'print sorted([1,1.0,2,2.0], reverse=True)'
[2.0, 2, 1.0, 1]

The implementation should be checked.

funny-falcon commented 6 years ago

Problem is in current reverse option implementation. It should not be implemented as reversed(sorted(l)), but as negation of comparison function.