Skip to content

Instantly share code, notes, and snippets.

@IMSoP
Created March 2, 2015 10:40
Show Gist options
  • Save IMSoP/4ea904203eadf8d5859a to your computer and use it in GitHub Desktop.
Save IMSoP/4ea904203eadf8d5859a to your computer and use it in GitHub Desktop.
Simplified Sortable Interface
<?php
/**
* This Interface allows to hook into the global Xsort() functions.
* @ingroup SPL
* @since PHP 7.0
*/
interface Sortable
{
/**
* Sort the entries by values.
*
* @param callable $cmp_function
* For usort(), will be passed the user's comparison callback.
* For sort(), rsort(), natsort(), natcasesort(), will be passed a comparison defined by the engine.
*/
public function sortValues(callable $cmp_function);
/**
* Sort the entries by values and maintain indexes.
*
* @param callable $cmp_function
* For uasort(), will be passed the user's comparison callback.
* For asort(), arsort(), will be passed a comparison defined by the engine.
*/
public function sortValuesAssoc(callable $cmp_function);
/**
* Sort the entries by key.
*
* @param callable $cmp_function
* For uksort(), will be passed the user's comparison callback.
* For ksort(), krsort(), will be passed a comparison defined by the engine.
*/
public function sortKeys(callable $cmp_function);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment