Drupal 8 - Sort multi arrays

// Import \Drupal\Component\Utility\SortArray class
use Drupal\Component\Utility\SortArray;

// Then applied it manually
uasort($result, function($a, $b) {
  return SortArray::sortByKeyString($a, $b, 'ARRAY_KEY_TO_SORT');
});

// Also It's possible to use without a closure function
uasort($form['elements'], [
  '\Drupal\Component\Utility\SortArray',
  'sortByWeightProperty'
]);