Skip to content

Incorrect sorting logic: "Low to High" displays descending order #30

@mondalanshu2006-wq

Description

@mondalanshu2006-wq

Observed behaviour:

  • Selecting "Low to High" shows products in descending order (highest price first)
  • Sorting behaviour is opposite of expected
  • UI label does not match actual sorting logic

Steps to reproduce:

  1. Go to Shop House
  2. Select "Low to High"
  3. Observe products are sorted from high to low

Expected behaviour:

  • "Low to High" should sort products in ascending order (lowest price first)

Actual behaviour:

  • Products are sorted in descending order instead

Root cause:

Sorting comparator logic is reversed:

result.sort((a, b) => (sortDirection === 'asc' ? b.price - a.price : a.price - b.price))

Fix:

Swap the comparator logic:

result.sort((a, b) => (sortDirection === 'asc' ? a.price - b.price : b.price - a.price))

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions