{"action":"created","issue":{"url":"https://api.github.com/repos/boostorg/compute/issues/588","repository_url":"https://api.github.com/repos/boostorg/compute","labels_url":"https://api.github.com/repos/boostorg/compute/issues/588/labels{/name}","comments_url":"https://api.github.com/repos/boostorg/compute/issues/588/comments","events_url":"https://api.github.com/repos/boostorg/compute/issues/588/events","html_url":"https://github.com/boostorg/compute/issues/588","id":150207229,"number":588,"title":"stable_sort_by_key is not stable when greater<T>() is used","user":{"login":"pavanky","id":364829,"avatar_url":"https://avatars.githubusercontent.com/u/364829?v=3","gravatar_id":"","url":"https://api.github.com/users/pavanky","html_url":"https://github.com/pavanky","followers_url":"https://api.github.com/users/pavanky/followers","following_url":"https://api.github.com/users/pavanky/following{/other_user}","gists_url":"https://api.github.com/users/pavanky/gists{/gist_id}","starred_url":"https://api.github.com/users/pavanky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pavanky/subscriptions","organizations_url":"https://api.github.com/users/pavanky/orgs","repos_url":"https://api.github.com/users/pavanky/repos","events_url":"https://api.github.com/users/pavanky/events{/privacy}","received_events_url":"https://api.github.com/users/pavanky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-21T22:20:59Z","updated_at":"2016-04-22T08:21:55Z","closed_at":null,"body":"- `sort_by_key` uses `radix_sort_by_key` which only supports `less<T>()`.\r\n- `sort_by_key` for `greater<T>()` [was implemented](https://github.com/boostorg/compute/pull/345) by simply reversing both the outputs from `less<T>()`. Which makes it **not** stable.\r\n- `stable_sort_by_key` just wraps `sort_by_key` thereby not being stable when `greater<T>` is called.\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/33210099-stable_sort_by_key-is-not-stable-when-greater-t-is-used?utm_campaign=plugin&utm_content=tracker%2F402515&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F402515&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/boostorg/compute/issues/comments/213321554","html_url":"https://github.com/boostorg/compute/issues/588#issuecomment-213321554","issue_url":"https://api.github.com/repos/boostorg/compute/issues/588","id":213321554,"user":{"login":"haahh","id":2720260,"avatar_url":"https://avatars.githubusercontent.com/u/2720260?v=3","gravatar_id":"","url":"https://api.github.com/users/haahh","html_url":"https://github.com/haahh","followers_url":"https://api.github.com/users/haahh/followers","following_url":"https://api.github.com/users/haahh/following{/other_user}","gists_url":"https://api.github.com/users/haahh/gists{/gist_id}","starred_url":"https://api.github.com/users/haahh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haahh/subscriptions","organizations_url":"https://api.github.com/users/haahh/orgs","repos_url":"https://api.github.com/users/haahh/repos","events_url":"https://api.github.com/users/haahh/events{/privacy}","received_events_url":"https://api.github.com/users/haahh/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T08:21:55Z","updated_at":"2016-04-22T08:21:55Z","body":"Ok. Thanks. Currently, I'm abroad but I'll look into it on Sunday or Monday.\n22 kwi 2016 09:36 \"Pavan Yalamanchili\" <notifications@github.com>\nnapisał(a):\n\n> Negating the input keys in the algorithms of radix_sort is a good idea\n> (quick and cheap in terms of performance), but it won't work for unsigned\n> keys. We need to locate the place in the radix_sort algorithm where we can\n> switch something and get descending order.\n>\n> Wouldn't the same place where you are doing float --> int transform for\n> sort on floats be ideal ? I think you just need to have another ifdef for\n> radix\n> <https://github.com/boostorg/compute/blob/master/include/boost/compute/algorithm/detail/radix_sort.hpp#L95>\n> function for descending order.\n>\n> On the other hand, we can just change unsigned values so 0 becomes\n> MAX_UINT etc. Would that work?\n>\n> This is exactly what we are doing\n> <https://github.com/shehzan10/arrayfire/blob/sort/src/backend/opencl/kernel/sort_by_key_impl.hpp#L85>\n> on our end as a work around for now.\n>\n> —\n> You are receiving this because you commented.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/boostorg/compute/issues/588#issuecomment-213303143>\n>\n"}}