Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#762 : fix float number sorting #763

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

xi-jjun
Copy link

@xi-jjun xi-jjun commented Jun 3, 2023

Issues

Implements Descriptions

  1. if item value is float type string
  2. then check floating number length for multiply own number
  3. after number is multiplied, then we make it to integer
  4. parse integer to string for using naturalSort

Example

  • 0.5 , 0.26
  • --> max floating number length is 2 (0.26 has 2)
  • multiply each
    • 0.5 --> 50
    • 0.26 --> 26
  • Then, we can sort these values like integer!

Test results

image

@codecov-commenter
Copy link

Codecov Report

Merging #763 (6db40c2) into develop (862caa2) will increase coverage by 0.12%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##           develop     #763      +/-   ##
===========================================
+ Coverage    93.54%   93.67%   +0.12%     
===========================================
  Files           19       19              
  Lines          837      854      +17     
  Branches       199      201       +2     
===========================================
+ Hits           783      800      +17     
  Misses          38       38              
  Partials        16       16              
Impacted Files Coverage Δ
src/sort.js 97.56% <100.00%> (+0.63%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -45,11 +45,30 @@ module.exports = function (list) {
},
}

function isFloatString(value) {
if (value === undefined || value === null || !value || typeof value !== 'string' || value.split(".").length !== 2) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    value.split(".").length !== 2

--> just check value(string type) has only one . because of ip sorting test case.

@lovasoa
Copy link

lovasoa commented Aug 3, 2023

Thanks. I merged that in https://www.npmjs.com/package/list.js-fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants