Skip to content

Float type number cant be sorted  #762

@xi-jjun

Description

@xi-jjun

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions