Skip to content

Fix: incorrect sorting logic (Low to High / High to Low)#33

Open
mondalanshu2006-wq wants to merge 1 commit intoGDSC-RCCIIT:mainfrom
mondalanshu2006-wq:fix/sorting-bug
Open

Fix: incorrect sorting logic (Low to High / High to Low)#33
mondalanshu2006-wq wants to merge 1 commit intoGDSC-RCCIIT:mainfrom
mondalanshu2006-wq:fix/sorting-bug

Conversation

@mondalanshu2006-wq
Copy link
Copy Markdown

Issue

Sorting logic was reversed:

  • "Low to High" showed descending order
  • "High to Low" showed ascending order

Fix

Corrected comparator logic:

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

### Result
- Sorting now works correctly
- UI matches expected behavior

@mondalanshu2006-wq
Copy link
Copy Markdown
Author

Hi I've fixed the sorting logic issue

"Low to High" and "High to Low" now work correctly.

please review . Happy to make further changes if needed.

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.

1 participant