diff --git a/src/Entity/Wishlist.php b/src/Entity/Wishlist.php
index 97924ccb743f29f8fd7af796b8b2be03fd9ec101..9c16360e90dd7fe7e5adfe93d8137a1594cb0313 100644
--- a/src/Entity/Wishlist.php
+++ b/src/Entity/Wishlist.php
@@ -125,7 +125,7 @@ class Wishlist
 
     public function getItemById(int $id){
         $itemsArray = (($this->items->toArray()))  ; 
-        for ($i = 0; $i < count($itemsArray); $i++) {
+        for ($i = 0; $i < sizeof($itemsArray); $i++) {
             $item = $itemsArray[$i];
             if ($item->getId() == $id ) {
                 return $item;
diff --git a/src/Repository/WishlistRepository.php b/src/Repository/WishlistRepository.php
index 93ae0c346f8f98da6aabcdbc5697fe72b343b3b6..25c14b1ca74920c7e68b0ceffc135acebe3c5928 100644
--- a/src/Repository/WishlistRepository.php
+++ b/src/Repository/WishlistRepository.php
@@ -42,21 +42,62 @@ class WishlistRepository extends ServiceEntityRepository
             $wishlist->setDeadline($deadline);
             $this->getEntityManager()->flush();
         }
+        return $wishlist;
     }
 
 
 
     public function mostExpensiveList() {
         $wishlists  = $this->findAll() ; 
+        $rankings = array();
+        foreach ($wishlists as $wishlist) {
+            $total =  $wishlist->wishlistTotalPrice() ; 
+            
+            if (sizeof(($rankings)) < 3  ) {
+                $rankings[] = ['wishlist' => $wishlist, 'total' => $total];
+                usort($rankings, callback: function($a, $b) {return $a['total'] - $b['total'];});
+            } else {
+                for ($i = 0; $i < sizeof($rankings) ; $i++ ) {
+                    if ($rankings[i]['total'] < $total ) {
+                        $rankings[i] = ['wishlist' => $wishlist, 'total' => $total] ; 
+                    }
+                } 
 
-        
+            }
+            
+        }
+        $result = array() ; 
+        for ($i =  0 ; $i < sizeof($rankings) ; $i++ ) {
+            $result[] = $rankings[i]['wishlist'] ; 
+        }
+        return $result;
+    }
+
+
+    public function mostExpensiveItems() {
+        $wishlists = $this->findAll() ; 
+        $rankings = array();
         foreach ($wishlists as $wishlist) {
             $items = $wishlist->getItems();
-        }
+            foreach ($items as $item) {
+                if ($item->getPurchaseProof()) {
+                    if (sizeof(($rankings)) < 3  ) {
+                        $rankings[] = $item;
+                        usort( $rankings, function($a, $b) {return $a->getPrice() - $b->getPrice();});
+                    } else {
+                        for ($i = 0; $i < sizeof($rankings) ; $i++ ) {
+                            if ($rankings[i]->getPrice() < $item->getPrice() ) {
+                                $rankings[i] = $item ; 
+                            }
+                        } 
         
+                    }
+                }
+            }
 
+        }
+        return $rankings;
     }
-
     //    /**
     //     * @return Wishlist[] Returns an array of Wishlist objects
     //     */