feat(gslice): Add partial sort for gslice#19
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
=======================================
Coverage 95.79% 95.79%
=======================================
Files 34 34
Lines 4443 4449 +6
=======================================
+ Hits 4256 4262 +6
Misses 144 144
Partials 43 43
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2a810cc to
cb39bfc
Compare
|
Hello, thank you for your contribution! Can you please give some real-world cases in the description? @XQ-Gang, I have been away from Go's code for a long time, and I don't know the current internal situation of ByteDance. I am not sure whether a function should be added (of course I will try to give suggestions). I think this decision should be made by you. |
I have updated the description. If anything else is needed, please let me know. |
@limits220284 有几个问题可以讨论
|
ad8eda5 to
54f88d2
Compare
54f88d2 to
97771ed
Compare
What
PartialSortsorts only the firstksmallest elements of a slice in ascending order. The rest of the elements are left unordered.kis 0 or less, nothing happens.kis greater than or equal to the slice length, the whole slice is sorted.Why
This is useful when you only need the smallest
kelements in order, instead of sorting the entire slice. It’s more efficient for large datasets when you only care about the top results.Motivation
Real World Example
kshortest jobs to run, without needing to sort all pending jobs.Aligns with similar patterns in other languages