@@ -148,7 +148,7 @@ getAllUsersQ = selectStar $ from $ table #users
148148getPostsByIdQ :: [PostId] -> Maybe (Query Schema '[] (RowPG PostRowResponse))
149149getPostsByIdQ pIds = case idsToColumn pIds of
150150 Just idQ -> Just $ selectDotStar #posts $ from (subquery (idQ `As` #ids) &
151− innerJoin (subquery $ getPostQ (orderBy [#posts ! #postRowId & Desc] . orderBy [#postElements ! #rowElementOrd & Asc]) id `As` #posts)
151+ innerJoin (subquery $ getPostQ (orderBy [#postElements ! #rowElementOrd & Asc] . orderBy [#posts ! #postRowId & Desc]) id `As` #posts)
152152 (#ids ! #id .== #posts ! #postRowId))
153153 Nothing -> Nothing
154154
@@ -162,7 +162,7 @@ isNotFalse x = UnsafeExpression $ renderExpression x <+> "IS NOT FALSE"
162162
163163getLastPostsQ :: TableEndo _ _ _ _ -> Limit -> Query Schema ('Null (PG Int64) ': params) (RowPG PostRowResponse)
164164getLastPostsQ te lim = getPostQ
165− (orderBy [#posts ! #postRowId & Desc] . orderBy [#postElements ! #rowElementOrd & Asc])
165+ (orderBy [#postElements ! #rowElementOrd & Asc] . orderBy [#posts ! #postRowId & Desc])
166166 (limit lim . te . where_ (isNotFalse $ #posts ! #postRowId .< param @1) . orderBy [#posts ! #postRowId & Desc])
167167
168168getLastNPostsForUserQ :: Limit -> Query Schema (TuplePG (Maybe PostId, UserId)) (RowPG PostRowResponse)
@@ -234,7 +234,7 @@ getChannelPostsQ
234234 (RowPG PostRowResponse)
235235getChannelPostsQ lim uIds tags = selectStar $ from (subquery $ postsQ' `As` #bar) &
236236 where_ ( isNotFalse $ #postRowId .< param @1) &
237− orderBy [#postRowId & Desc] . orderBy [#rowElementOrd & Asc] & limit lim
237+ orderBy [#rowElementOrd & Asc] & limit lim . orderBy [#postRowId & Desc]
238238 where
239239 unionWithUsers = case idsToColumn uIds of
240240 Just uIdsQ -> selectDotStar #posts' (from $ subquery (uIdsQ `As` #uIds) &