Skip to content

Instantly share code, notes, and snippets.

@maxout
Created December 10, 2014 22:53
Show Gist options
  • Save maxout/7d341509365b267430d3 to your computer and use it in GitHub Desktop.
Save maxout/7d341509365b267430d3 to your computer and use it in GitHub Desktop.
Sorting sizes
function usortFunction($g1, $g2) {
$sortierung = Array("XXXS" => 1, "XXS" => 2, "XS" => 3, "S" => 4, "M" => 5, "L" => 6, "XL" => 7, "XXL" => 8, "XXXL" => 9, "XXXXL" => 10);
$index1 = $sortierung[strtoupper($g1)];
$index2 = $sortierung[strtoupper($g2)];
return ($index1 < $index2) ? -1 : 1;
}
usort($groessen, "usortFunction");
/*
* advanced
*/
/*
function usortFunction($g1, $g2) {
$sort=array( “XXXS”, “XXS” , “XS”, “S”, “M”, “L”, “XL”, “XXL”, “XXXL”, “XXXXL”, “XXXXXL”, “XXXXXXL”, “2XL”, “3XL”, “4XL”, “5XL”, “6XL”, “36”, “38”, “40”, “42”, “44”, “46”, “48”, “98”, “104”, “110”, “116”, “122”, “128”, “134”, “140”, “146”, “152”, “158”, “164”, “170”, “182 “, “188” );
$sortierung =array_flip($sort);
$index1 = $sortierung[strtoupper($g1)];
$index2 = $sortierung[strtoupper($g2)];
return ($index1 < $index2) ? -1 : 1;
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment