fix(sorting): use natural version ordering instead of lexicographic#3791
Open
himanshu07gupta wants to merge 1 commit intoeclipse-sw360:mainfrom
Open
fix(sorting): use natural version ordering instead of lexicographic#3791himanshu07gupta wants to merge 1 commit intoeclipse-sw360:mainfrom
himanshu07gupta wants to merge 1 commit intoeclipse-sw360:mainfrom
Conversation
47ab944 to
0d9b7a9
Compare
Replace lexicographic String.CASE_INSENSITIVE_ORDER with a new NaturalVersionComparator for version string sorting. Lexicographic ordering incorrectly places "15.0" before "2.0" because character '1' < '2', and "1.1 SR1" before "1.1" due to space/bracket comparison. The new comparator splits version strings into numeric and non-numeric segments, comparing numeric parts as integers. This produces the correct order: 1.0, 1.1, 1.1 SR1, 2.0, 15.0. Fixes eclipse-sw360#206 Fixes eclipse-sw360#236 Signed-off-by: Himanshu Gupta <himanshu07gupta@gmail.com> Signed-off-by: himanshu07gupta <himanshu29gupta0703@gmail.com>
0d9b7a9 to
31c3b5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview: Solving two sorting issue mentioned in #206, #236. The current version sorting uses
String.CASE_INSENSITIVE_ORDER(lexicographic ordering) which produces incorrect results:15.0sorts before2.0because character'1'<'2'1.1 SR1sorts before1.1due to space/bracket character comparisonThis PR introduces a
NaturalVersionComparatorthat splits version strings into numeric and non-numeric segments, comparing numeric parts as integers instead of strings.Before (broken):
1.0, 1.1, 1.1 SR1, 10.0, 15.0, 2.0, 3.0After (fixed):
1.0, 1.1, 1.1 SR1, 2.0, 3.0, 10.0, 15.0Issue: #206, #236
Fixes #206
Fixes #236
Suggest Reviewer
@GMishx @mcjaeger Could you please review or assign someone to this pr? Please let me know if any edge case is missing.
How To Test?
Screen.Recording.2026-03-03.at.10.43.51.PM.1.mov
15.0,2.0,1.0,10.0,3.0,1.1,1.1 SR1GET /resource/api/projects/{projectId}/releases?sort=version,asc1.0, 1.1, 1.1 SR1, 2.0, 3.0, 10.0, 15.0Checklist
Must: