GROOVY-11653: Create DGM#sort(List) and AGM#sort(T[]) variants that t…#2213
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2213 +/- ##
==================================================
+ Coverage 68.9801% 68.9837% +0.0036%
- Complexity 29625 29632 +7
==================================================
Files 1423 1423
Lines 114217 114240 +23
Branches 19818 19823 +5
==================================================
+ Hits 78787 78807 +20
Misses 28802 28802
- Partials 6628 6631 +3
🚀 New features to boost your workflow:
|
|
+1 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds new sort variants that allow sorting within a specific index range for both Lists and arrays, using a Closure to determine the ordering. Key changes include updated documentation on sort behavior, added overloads for sort methods that accept an IntRange, and the introduction of a toSorted method for Lists with index range support.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | Adds subrange sort methods for List, with both in-place mutation and non-mutating variants. |
| src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java | Adds subrange sort methods for arrays, supporting both in-place and non-mutating operations. |
Comments suppressed due to low confidence (1)
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:13491
- [nitpick] Consider updating only the sorted subrange by using self.subList(info.from, info.to) to replace the elements, which may improve clarity and focus the mutation on just the intended range.
for (T e : a) { i.next(); i.set(e); }
…ake an IntRange