Skip to content

Commit

Permalink
chore: Fix sorting issue in PhotoGridByYear component
Browse files Browse the repository at this point in the history
This commit fixes a sorting issue in the PhotoGridByYear component. The index difference calculation in the `PhotoGridByYear` component was incorrect, causing the sorting to be reversed. This commit corrects the calculation to ensure the correct sorting order is maintained.

```
  • Loading branch information
azat-ismagilov committed Aug 2, 2024
1 parent dfe2150 commit d255c90
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Body/PhotoGridByYear.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const PhotoGridByYear = ({ photos, handleClick }) => {
const yearA = a[0];
const yearB = b[0];
const yearIndex = (targetYear) => places.findIndex(({ year }) => year === targetYear);
const indexDiff = yearIndex(yearA) - yearIndex(yearB);
const indexDiff = yearIndex(yearB) - yearIndex(yearA);
if (indexDiff !== 0) {
return indexDiff;
}
Expand Down

0 comments on commit d255c90

Please sign in to comment.