perf-enhancement: Add Vector_sort function w/ context support#1792
perf-enhancement: Add Vector_sort function w/ context support#1792j-a-c-k-goes wants to merge 1 commit intohtop-dev:mainfrom
Conversation
Consolidates vector sorting functions as mentioned in issue htop-dev#1785. Implements Highlander Rule by providing single sorting function. Features: - Context-aware comparison functions for sorting logic - Hybrid algo: insertion sort <=16 elements, quicksort >16 elements - Backward compatible. Existing functions unchanged - NULL-safe context handling Performance benefits: - Algo selection based on array sizing - Faster inserts on large arrays than w/ pure insertion sort - Standard 16 element thresh for algo switching This address issue htop-dev#1785 w/o breaking existing code. Future commits can migrate call sites to use Vector_sort gradually (if merged)
|
Hi. Good contribution, but I have a concern on using quicksort, which can break stability in sorting. The original code uses insertionSort probably because it's a stable sort, or because it deals with data that are more often partially sorted. So when it comes to consolidating sorting function, I would consider any unstable sorting function be out. |
|
@Explorer09 are you finding the implemented sort to be unstable? Could retest, but initial tests were not unstable. |
@j-a-c-k-goes |
PR_DESCRIPTION.md
Add Vector_sort function with context support
Consolidates vector sorting functions as requested in issue #1785.
Implements "Highlander rule" via providing single preferred
sorting function while maintaining backward compatibility.
Features:
Performance benefits:
This addresses issue #1785 without breaking existing code.
Future commits can gradually migrate call sites to use
Vector_sort.Signed-off-by: [_ack] <[jack@flnpb.comy]>