Order relationship in RESTful
I've resolved the sorting problem with sorting data inside the formatter. Here's my code in case someone had similar problems.

&lt;?php

/**
 * @file
 * Contains \Drupal\restful\Plugin\formatter\OrderFormatter.
 */

namespace Drupal\my_module\Plugin\formatter;

use Drupal\restful\Plugin\formatter\FormatterJson;
use Drupal\restful\Plugin\formatter\FormatterInterface;

/**
 * Class OrderFormatter
 * @package Drupal\restful\Plugin\formatter
 *
 * @Formatter(
 *   id = "order_formatter",
 *   label = "ORDER FORMATTER",
 *   description = "Output filtered data",
 *   curie = {
 *     "name": "dis",
 *     "path": "doc/rels",
 *     "template": "/{rel}",
 *   },
 * )
 */
class OrderFormatter extends FormatterJson implements FormatterInterface {

  /**
   * Content Type
   *
   * @var string
   */
  protected $contentType = 'application/json+sort; charset=utf-8';

  /**
   * {@inheritdoc}
   */
  public function render(array $structured_data) {
    $i=0;
    foreach ($structured_data['data'] as $v) {

      $structured_data['data'][$i]['unsortedThings'] = $this-&gt;sortBy($structured_data['data'][$i]['unsortedThings']);
      $i++;
    }
    return drupal_json_encode($structured_data);
  }

  public function sortBy($arr) {
    $results = [];
    foreach ($arr as $k=&gt;$v) {
      $results[$k] = $v['weight']; //this is my sorting field
    }
    asort($results, SORT_REGULAR);

    foreach (array_keys($results) as $key) {
      $results[$key] = $arr[$key];
    }
    $results = array_values($results);
    return $results;
  }

}


You run this formatter by adding header to your request: Accept: application/json+sort; charset=utf-8