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

Float type number cant be sorted #762

Open
xi-jjun opened this issue Jun 3, 2023 · 0 comments
Open

Float type number cant be sorted #762

xi-jjun opened this issue Jun 3, 2023 · 0 comments

Comments

@xi-jjun
Copy link

xi-jjun commented Jun 3, 2023

Issue

When i sort the floating numbers by list js sort function, there is some problem.

Problem

I find some problem in sort.test.js code.

The test data is incomplete. That test should be compensated by using another test data.

Suggestion

Here is what i suggested.

...
    // my suggestion
    it('should show order of sorted floates (a bit wrong)', function () {
      i1.values({ val: '0.5' })
      i2.values({ val: '0.26' })
      i3.values({ val: '0.040' })
      i4.values({ val: '0.50' })
      i5.values({ val: '0.500' })
      i6.values({ val: '0.3' })
      list.sort('val', { order: 'asc' })
      expect(list.items[0].values().val).toBe('0.040')
      expect(list.items[1].values().val).toBe('0.26')
      expect(list.items[2].values().val).toBe('0.3')
      expect(list.items[3].values().val).toBe('0.5')
      expect(list.items[4].values().val).toBe('0.50')
      expect(list.items[5].values().val).toBe('0.500')
    })
...

Test result

image
  • list js sort floating number by ..
  • So when list js compare 0.5 and 0.26, 0.26 is bigger than 0.5 because list js recognize 0.5 to 5 and 0.26 to 26.
xi-jjun added a commit to xi-jjun/list.js that referenced this issue Jun 3, 2023
xi-jjun added a commit to xi-jjun/list.js that referenced this issue Jun 3, 2023
xi-jjun added a commit to xi-jjun/list.js that referenced this issue Jun 3, 2023
xi-jjun added a commit to xi-jjun/list.js that referenced this issue Jun 3, 2023
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

No branches or pull requests

1 participant