Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
roqua-support
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RoQua
roqua-support
Commits
8339ff1d
Commit
8339ff1d
authored
3 years ago
by
Henk
Browse files
Options
Downloads
Patches
Plain Diff
Make sort_by_alphanum consistent for chunks that parse to the same int like 04 and 4.
parent
35e0284e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
Make sort_by_alphanum stable
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/roqua/core_ext/enumerable/sort_by_alphanum.rb
+1
-1
1 addition, 1 deletion
lib/roqua/core_ext/enumerable/sort_by_alphanum.rb
spec/roqua/core_ext/enumerable/sort_by_alphanum_spec.rb
+5
-0
5 additions, 0 deletions
spec/roqua/core_ext/enumerable/sort_by_alphanum_spec.rb
with
6 additions
and
1 deletion
lib/roqua/core_ext/enumerable/sort_by_alphanum.rb
+
1
−
1
View file @
8339ff1d
...
...
@@ -26,7 +26,7 @@ module Enumerable
a_chunk
,
a
=
extract_alpha_or_number_group
(
a
)
b_chunk
,
b
=
extract_alpha_or_number_group
(
b
)
ret
=
if
a_chunk
=~
/\d/
and
b_chunk
=~
/\d/
ret
=
if
a_chunk
=~
/\d/
&&
b_chunk
=~
/\d/
&&
a_chunk
.
to_i
!=
b_chunk
.
to_i
a_chunk
.
to_i
<=>
b_chunk
.
to_i
else
a_chunk
<=>
b_chunk
...
...
This diff is collapsed.
Click to expand it.
spec/roqua/core_ext/enumerable/sort_by_alphanum_spec.rb
+
5
−
0
View file @
8339ff1d
...
...
@@ -14,5 +14,10 @@ describe Enumerable do
it
'compares number chunks as integers'
do
expect
(
%w(004 3)
.
sort_by_alphanum
).
to
eq
%w(3 004)
end
it
'sorts identical integers by asci'
do
input
=
%w[b4e b0004e b04e b004e]
expect
(
input
.
sort_by_alphanum
).
to
eq
%w[b0004e b004e b04e b4e]
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment