NaturalSortByMultiField

The Contact Form DB NaturalSortByMultiField class.

Defined (1)

The class is defined in the following location(s).

/NaturalSortByMultiField.php  
  1. class NaturalSortByMultiField extends SortTransform { 
  2.  
  3. var $fields = array(); 
  4.  
  5. // todo: replace with splat operator when PHP 5.6 is minimal version 
  6. function __construct($fieldName0,  
  7. $fieldName1 = null,  
  8. $fieldName2 = null,  
  9. $fieldName3 = null,  
  10. $fieldName4 = null,  
  11. $fieldName5 = null,  
  12. $fieldName6 = null,  
  13. $fieldName7 = null,  
  14. $fieldName8 = null,  
  15. $fieldName9 = null) { 
  16. $this->fields[0] = $fieldName0; 
  17. $this->fields[1] = $fieldName1; 
  18. $this->fields[2] = $fieldName2; 
  19. $this->fields[3] = $fieldName3; 
  20. $this->fields[4] = $fieldName4; 
  21. $this->fields[5] = $fieldName5; 
  22. $this->fields[6] = $fieldName6; 
  23. $this->fields[7] = $fieldName7; 
  24. $this->fields[8] = $fieldName8; 
  25. $this->fields[9] = $fieldName9; 
  26.  
  27. public function sort($a, $b) { 
  28. $result = 0; 
  29. for ($idx = 0; $idx <= 9; ++$idx) { 
  30. if ($result == 0 && $this->fields[$idx]) { 
  31. $result = strnatcmp($a[$this->fields[$idx]], $b[$this->fields[$idx]]); 
  32. if ($result != 0) { 
  33. break; 
  34. return $result;