{"comment":{"created_at":"2011-10-07T20:57:39Z","body":"Another interesting ordering to look at would be none, which would just put the args of the Add in whatever order they happen to be in at the end of the flatten routine.  The problem, if I recall, is that many things (such as `Basic.__eq__`) rely on arg ordering being canonicalized to work correctly.  This is probably something that can't really be changed, as it's a nice property to have, but it's might be worth at least looking at.","updated_at":"2011-10-07T20:57:39Z","url":"https://api.github.com/repos/sympy/sympy/issues/comments/2328171","id":2328171,"user":{"avatar_url":"https://secure.gravatar.com/avatar/0383e4cae325f65a1bbd906be4be2276?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/asmeurer","id":71486,"login":"asmeurer"}},"action":"created","issue":{"number":637,"created_at":"2011-10-07T20:50:06Z","pull_request":{"diff_url":"https://github.com/sympy/sympy/pull/637.diff","patch_url":"https://github.com/sympy/sympy/pull/637.patch","html_url":"https://github.com/sympy/sympy/pull/637"},"body":"Now both `sort_key()` and `default_sort_key()` return only comparable objects (tuples, strings, numbers). I also added a new switch `-A` to isympy, test and doctest, which allows to choose sorting algorithm for `Add.args`: `hash`, `random` or `sort_key`. `hash` is the default. `random` doesn't really give much, because almost whole SymPy fails with this. But `sort_key` is very useful and allows to reproduce problems that we have under PyPy (for example). If you run `bin/test -A sort_key`, then all tests pass besides well know `piecewise_fold`. There are also doctest failures if your run `bin/doctest -A sort_key`, but you will see that this is only a coincidence that they pass with `-A hash`. SymPy is about 5% slower when running tests with `-A sort_key`. It should be possible to reduce this by using customized caching for `sort_key()` (as we use for `__hash__()`).","comments":1,"title":"Robustified sort_key() and default_sort_key()","updated_at":"2011-10-07T20:57:39Z","url":"https://api.github.com/repos/sympy/sympy/issues/637","id":1848782,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/89164142ec718a76a7e04481062acaea?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/mattpap","id":27475,"login":"mattpap"},"html_url":"https://github.com/sympy/sympy/issues/637","labels":[],"state":"open"},"legacy":{"issue_id":1848782,"comment_id":2328171}}