-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global compare FCI should be saved and restored (allowing nested comparators) #48
Comments
Why does this need a global at all? |
Because we need to call a user function inside a comparator (C function pointer). |
Why can't it be passed along as a context pointer? As you aren't using zend_hash_sort, you shouldn't be limited by a context-free comparator. |
I don't believe qsort supports a context parameter. |
Huh, you're right. I could have sworn there was a qsort_ex variant, but looks like there isn't :( |
There is, but it's not standard. I wonder how plausible it is to implement quick sort manually. |
There are two variants commonly found: Perhaps we could use this: https://github.com/noporpoise/sort_r. It is in the public domain, so no issue there. |
@morrisonlevi interesting idea, would be very easy to just nab that header file and include it. I like. |
Coming back to this 2 years later, do we think that a third party sort is still the way to go? |
@morrisonlevi the sort_r lib you linked falls back to their own quicksort implementation, but uses qsort_r if it is available. Seems reasonable to me to just include that header then. Might look for some others too.. |
All structures share the same global FCI, so if while sorting something you try to sort something else, things will break. The best way to handle this is to save the current FCI, use it, then restore it.
The text was updated successfully, but these errors were encountered: