w = $width; $this->h = $height; } // Convert to string public function __toString() { return "width: " . $this->w . "\n" . "height: " . $this->h . "\n" . "\n"; } // Calculate rectangle area public function area() { return $this->w * $this->h; } // Other method (not rilevant) // ... public static function order(&$rectangles) { uasort($rectangles, 'rectangle::order_info'); } private static function order_info(rectangle $a, rectangle $b) { if ($a->area() < $b->area()) { return -1; } else { return 1; } } } $rectangles = array(); for($i = 0; $i < 10; $i++ ) { $width = rand(1, 100); $height = rand(1, 100); $rec = new rectangle($width, $height); $rectangles[$rec->area()] = $rec; } print_r($rectangles); rectangle::order($rectangles); print_r($rectangles);