title: How to sort serialized fields with Django Rest Framework
body: <p>I'm looking for suggestions on how to sort/group serialized fields by value. 
  Here's a code example explaining what I want to achieve.</p>
  
  <p>Models</p>
  
  <pre><code>class Folder(models.Model):
      name = models.CharField()
  
  
  class File(models.Model):
      filetype = models.CharField()
      name = models.CharField()
      folder = models.ForeignKey(Folder)
  </code></pre>
  
  <p>Serializers</p>
  
  <pre><code>class FileSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = File
          fields = ('id', 'filetype', 'name')
  
  
  class FolderSerializer(serializers.ModelSerializer):
  
      files = FileSerializer(read_only=True)
  
      class Meta:
          model = Folder
          fields = ('name', 'files')
  </code></pre>
  
  <p>This serializes to:</p>
  
  <pre><code>{
      "name": "Test Folder",
      "files": [
          {"id": 1, "filetype": "pdf", "name": "some pdf file"}.
          {"id": 2, "filetype": "pdf", "name": "some other pdf file"},
          {"id": 3, "filetype": "txt", "name": "some text file"}
      ]
  }
  </code></pre>
  
  <p>I'm looking for a way to serialize to this:</p>
  
  <pre><code>{
      "name": "Test Folder",
      "files": [
          "pdf": [
              {"id": 1, "name": "some pdf file"},
              {"id": 2, "name": "some other pdf file"}
          ],
          "txt": [
              {"id": 3, "name": "some text file"}
          ]
      ]
  }
  </code></pre>