grumpyhome / grumpy

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

Implement the 'reverse' option for sorted() #82

Closed alanjds closed 6 years ago

alanjds commented 6 years ago

google/grumpy#162 opened on Jan 18, 2017 by @MirkoDziadzka

Add the 'reverse' option to 'sorted()'

I'm not sure if this violates the 'stable sort definition in Python. On the other hand, this is probably only relevant when key or cmp gets implemented.

alanjds commented 6 years ago

Comment by trotterdylan Friday Jan 20, 2017 at 16:17 GMT


That all sounds good. Let me know when I should review again.

funny-falcon commented 6 years ago

While #102 is merged, it is not proper implementation, even without implementation of key or cmp:

$ python -c 'print sorted([1,1.0,2,2.0], reverse=True)'
[2, 2.0, 1, 1.0]
$ grumpy-runtime-src/build/bin/grumprun -c 'print sorted([1,1.0,2,2.0], reverse=True)'
[2.0, 2, 1.0, 1]

It will certainly affect types which implements comparison methods.

alanjds commented 6 years ago

:/ It may be about stability too. The sort code should be checked.

alanjds commented 6 years ago

Closing in favor of #120