code: public function write()
      {
          $data = array();
          $dumper = new ArrayDumper();
  
          foreach ($this->getCanonicalPackages() as $package) {
              $data[] = $dumper->dump($package);
          }
  
          usort($data, function ($a, $b) {
              return strcmp($a['name'], $b['name']);
          });
  
          $this->file->write($data);
      }
docs: Writes writable repository.