{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/6357","labels_url":"https://api.github.com/repos/numpy/numpy/issues/6357/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6357/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/6357/events","html_url":"https://github.com/numpy/numpy/issues/6357","id":108264106,"number":6357,"title":"argsort(argsort()) behavior not stable?","user":{"login":"wendykan","id":912546,"avatar_url":"https://avatars.githubusercontent.com/u/912546?v=3","gravatar_id":"","url":"https://api.github.com/users/wendykan","html_url":"https://github.com/wendykan","followers_url":"https://api.github.com/users/wendykan/followers","following_url":"https://api.github.com/users/wendykan/following{/other_user}","gists_url":"https://api.github.com/users/wendykan/gists{/gist_id}","starred_url":"https://api.github.com/users/wendykan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wendykan/subscriptions","organizations_url":"https://api.github.com/users/wendykan/orgs","repos_url":"https://api.github.com/users/wendykan/repos","events_url":"https://api.github.com/users/wendykan/events{/privacy}","received_events_url":"https://api.github.com/users/wendykan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-25T05:03:00Z","updated_at":"2015-09-25T05:15:09Z","closed_at":null,"body":"When sorting a list of exactly the same values, when the length is < 16, the order is preserved, when length > 16, the order is scattered. \r\n\r\n    >>> np.argsort(np.argsort([2]*16))\r\n    array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15])\r\n\r\n    >>> np.argsort(np.argsort([2]*17))\r\n    array([ 0, 14, 13, 12, 11, 10,  9, 15,  8,  6,  5,  4,  3,  2,  1,  7, 16])\r\n\r\nThis is avoided when it's sorted by mergesort:\r\n\r\n    >>> np.argsort(np.argsort([2]*17,kind='mergesort'),kind='mergesort')\r\n    array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16])\r\n"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/143129141","html_url":"https://github.com/numpy/numpy/issues/6357#issuecomment-143129141","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6357","id":143129141,"user":{"login":"njsmith","id":609896,"avatar_url":"https://avatars.githubusercontent.com/u/609896?v=3","gravatar_id":"","url":"https://api.github.com/users/njsmith","html_url":"https://github.com/njsmith","followers_url":"https://api.github.com/users/njsmith/followers","following_url":"https://api.github.com/users/njsmith/following{/other_user}","gists_url":"https://api.github.com/users/njsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/njsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njsmith/subscriptions","organizations_url":"https://api.github.com/users/njsmith/orgs","repos_url":"https://api.github.com/users/njsmith/repos","events_url":"https://api.github.com/users/njsmith/events{/privacy}","received_events_url":"https://api.github.com/users/njsmith/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T05:15:09Z","updated_at":"2015-09-25T05:15:09Z","body":"Yeah, there's a little table in [the documentation] (http://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html) explaining that of the supported sorting modes, only mergesort is stable.\r\n\r\n@charris: if people are being confused because they expect default sorts to be stable in python, I guess that's kind of an argument for making mergesort the default. And it'd be backwards compatible because it only guarantees more than the current default. But I assume there's some good reason why not, like it's noticeably slower or something?"}}