Open shlyakpavel opened 2 weeks ago
I'm not sure whether the current behavior is intentional or a bug, but our quick_sort
implementation seems to behave as your test expects. You can see this if you substitute insertion_sort
for dual_pivot_quick_sort
in the above test.
I think it would be best if the behavior was consistent across different sorts.
Deleted. Stupid stuff
I think it would be useful to create a test class that measures the number of times an instance is swapped or compared using the comparator.
Doing so would let us validate that while quick_sort behaves the same with either implementation, it does less compares/swaps in one implementation over another.
Or some benchmarks.
Intuitively, the current implementation seems incorrect, but in its current uses that incorrect behavior doesn't seem to affect the correctness of the calling code.
I am unable to understand how this is not a bug?
https://github.com/LadybirdBrowser/ladybird/blob/dd11d48a1dcc96a77f4e11bd72f558503057e775/AK/InsertionSort.h#L14-L23
Is this code supposed to start at the beginning and end at the end? If so, should not be the inner loop be something like
Here's a test that indicated what I'm worried about
It fails. So either I don't get the idea how it's supposed to work or it's just not working as expected....