pytest-dev / pytest-dev/pytest-html

Got incorrect sort when the content of cell is the numeric value of the float type.

Open
#818 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
779
Forks
260
PR merge metrics
No merged PRs in 30d

Description

I insert one cell to store the numeric value of the float type in summary section as following shown.
cells.insert(11, '<th class="sortable" data-column-type="speedup">speedup</th>')

And the speedup is the numeric value of the float type.

In genericSort fuction, convert the value of cell into lowcase, I think should check whether the value is a numeric type.
If yes, should return parseFloat(a[key]) - parseFloat(b[key])

sorted = list.sort((a, b) => { if (!isNaN(parseFloat(a[key])) && !isNaN(parseFloat(a[key]))){ return parseFloat(a[key]) - parseFloat(b[key]) } return a[key] === b[key] ? 0 : a[key] > b[key] ? 1 : -1 })

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the genericSort function responsible for sorting the inserted summary cells, starting from the speedup column described in the issue. Check how float values are compared versus lowercased strings, then verify that numeric speedup values sort by their numeric value while nonnumeric values retain the existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.