public static function sortByKey($data, $sortKey, $sort_flags = SORT_ASC)
  {
      if (empty($data) or empty($sortKey)) {
          return $data;
      }

      $ordered = [];
      $i = 0;
      foreach ($data as $key => $value) {
          ++$i;
          $ordered[$value[$sortKey].'-'.$i] = $value;
      }

      switch ($sort_flags) {
      case SORT_ASC:
        ksort($ordered, SORT_NUMERIC);
      break;
      case SORT_DESC:
        krsort($ordered, SORT_NUMERIC);
      break;
    }

      return array_values($ordered);
  }