public static function PriceList::sort in Commerce Pricelist 8.2
Helper callback for uasort() to sort price lists by weight and label.
Parameters
\Drupal\commerce_pricelist\Entity\PriceListInterface $a: The first price list to sort.
\Drupal\commerce_pricelist\Entity\PriceListInterface $b: The second priice list to sort.
Return value
int The comparison result for uasort().
File
- src/
Entity/ PriceList.php, line 431
Class
- PriceList
- Defines the Price list entity.
Namespace
Drupal\commerce_pricelist\EntityCode
public static function sort(PriceListInterface $a, PriceListInterface $b) {
$a_weight = $a
->getWeight();
$b_weight = $b
->getWeight();
if ($a_weight == $b_weight) {
$a_label = $a
->label();
$b_label = $b
->label();
return strnatcasecmp($a_label, $b_label);
}
return $a_weight < $b_weight ? -1 : 1;
}