diff --git a/service/src/main/scala/com/github/mmvpm/service/dao/offer/OfferDaoPostgresql.scala b/service/src/main/scala/com/github/mmvpm/service/dao/offer/OfferDaoPostgresql.scala index 5e24d07..422e4b5 100644 --- a/service/src/main/scala/com/github/mmvpm/service/dao/offer/OfferDaoPostgresql.scala +++ b/service/src/main/scala/com/github/mmvpm/service/dao/offer/OfferDaoPostgresql.scala @@ -45,7 +45,9 @@ class OfferDaoPostgresql[F[_]: MonadCancelThrow](implicit val tr: Transactor[F]) offers <- offersEntries.traverse { offersEntry => selectFromPhotos(offersEntry.id).map(offersEntry.toOffer) } - } yield offers) + orderFromRequest = offerIds.zipWithIndex.toMap + offersOrdered = offers.sortBy(o => orderFromRequest.getOrElse(o.id, Int.MaxValue)) + } yield offersOrdered) .transact(tr) .attemptT .leftMap(error => InternalOfferDaoError(error.getMessage))