Skip to content

Conversation

jszuppe
Copy link
Contributor

@jszuppe jszuppe commented Apr 23, 2016

This should fix #588.

Now in radix sort when greater<T>() is specified as comparison function (desc order) instead of performing asc-ordered radix sort and then reversing the result, descending radix sort is performed.

It's done by negating input value if its type is a signed type and by subtracting the input value from the maximum value of value's type in other cases (in radix() function). That way values seem "reversed" and we get desc order. It should also be faster than sorting in asc order and then reversing the result.

I also added some test for desc-ordered radix sort and radix sort by key.

jszuppe added 2 commits April 23, 2016 18:21
Radix sort algorithm was not stable when used for
sorting by key in descending order (see issue boostorg#588).
@pavanky
Copy link
Contributor

pavanky commented Apr 23, 2016

looks good 👍

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.791% when pulling f29bbda on haahh:pr_sort_by_key_desc_fix into 437363b on boostorg:develop.

@kylelutz kylelutz merged commit 48217d2 into boostorg:develop Apr 24, 2016
@jszuppe jszuppe deleted the pr_sort_by_key_desc_fix branch April 24, 2016 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants