Skip to content

Instantly share code, notes, and snippets.

@koriym
Last active November 4, 2020 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koriym/5a02cd11ff43adf839a8c92cd66f50c2 to your computer and use it in GitHub Desktop.
Save koriym/5a02cd11ff43adf839a8c92cd66f50c2 to your computer and use it in GitHub Desktop.
PHP spaceship operator example
usort($descriptors, function (AbstractDescriptor $a, AbstractDescriptor $b): int {
    $order = ['semantic' => 0, 'safe' => 1, 'unsafe' => 2, 'idempotent' => 3];
    
    return $order[$a->type] <=> $order[$b->type]; // sort by type
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment