Skip to content

fixed sorting by ID bug#218

Merged
its-me-abhishek merged 1 commit intoCCExtractor:mainfrom
Neeraj-gagat:bug/sorting-function
Nov 25, 2025
Merged

fixed sorting by ID bug#218
its-me-abhishek merged 1 commit intoCCExtractor:mainfrom
Neeraj-gagat:bug/sorting-function

Conversation

@Neeraj-gagat
Copy link
Copy Markdown
Contributor

Description

Previously, sorting tasks manually (e.g., by ID or description) would appear to work initially, but the order would be unexpectedly overridden whenever filters or other state changes triggered a re-render. The source of the problem was that sortWithOverdueOnTop() always applied a second sort — forcing sorting by ID again — which erased the user’s intended sort order.

What was causing it:

The useEffect that filters tasks also re-applied sorting.
Inside sortWithOverdueOnTop(), we performed:
return b.id - a.id;
Which forced DESC ID sorting again every time the effect ran, overriding any custom sorting logic.

Fix introduced:

Updated sortWithOverdueOnTop() to only enforce the overdue-first rule, without altering the order of non-overdue tasks:
return 0;
This preserves the user’s chosen sorting order while still keeping overdue tasks at the top.
Ensured that manual sorting functions (handleIdSort, handleSort) continue to work correctly without unexpected overrides.

Result:

✔ Overdue tasks always stay on top
✔ User-initiated sorting (ID, alphabetical, etc.) is preserved
✔ No more sorting conflicts when filters or state updates occur
✔ Improved UX consistency in the Tasks table

- Fixes: #215

video after changes

Screencast.from.22-11-25.11.30.02.PM.IST.webm

@its-me-abhishek its-me-abhishek merged commit 7eaf791 into CCExtractor:main Nov 25, 2025
4 checks passed
ShivaGupta-14 pushed a commit to ShivaGupta-14/ccsync that referenced this pull request Dec 25, 2025
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.

Bug: sorting Function (sort by ID)

2 participants