diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index cd704c2..be93b0d 100644 --- a/app/lib/actions/locationActions.ts +++ b/app/lib/actions/locationActions.ts @@ -98,7 +98,11 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, pageIx: // fetch `pageSize` locations for the given page index const locations = await dbClient.collection("lokacije") .find({ userId }) - .sort({ yearMonth: -1, name: 1 }) + .sort({ + "yearMonth.year": -1, + "yearMonth.month": -1, + name: 1, + }) .skip(pageIx * pageSize) .limit(pageSize) .toArray();