SortInterface.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * SortInterface.php
  5. *
  6. * @author: marand
  7. *
  8. * @license General Public License version 2 or later
  9. */
  10. namespace OSInet\Sort;
  11. interface SortInterface {
  12. /**
  13. * @param string $type
  14. * The name of the sort algorithm: bubble, heap, insertion, merge, quick,
  15. * selection, and so on.
  16. *
  17. * @return SortInterface
  18. */
  19. public static function create($type);
  20. /**
  21. * @param array $data
  22. * The data to sort. It will not be modified in place.
  23. * @param callable $comparison
  24. * The comparison callback. It must take two Sortable parameters, and
  25. * return less than 0 if the first is lower than the second, 0 if they are
  26. * equal, and more than 0 if the first is higher than the second. It may
  27. * take a third array parameter, which will receive the $options array.
  28. * @param array $options
  29. * A hash of options for the comparison function.
  30. *
  31. * @return array
  32. * The sorted version of the input data.
  33. */
  34. public function sort($data, $comparison, $options = array());
  35. }