[ create a new paste ] login | about

Link: http://codepad.org/vxcN29sO    [ raw code | output | fork ]

PHP, pasted on Oct 25:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

$array = array(
    '66-507cddcd16d9786abafccfa78b19acf8' => 'XL',
    '64-507cddcd16d9786abafccfa78b19acf8' => 'M',
    '65-507cddcd16d9786abafccfa78b19acf8' => 'L',
    '63-507cddcd16d9786abafccfa78b19acf8' => 'S'
);


function sizeSorter($a, $b) {
    // customize as needed
    $comp = array_flip(array('xxxs', 'xxs', 'xs', 's', 'small', 'm', 'medium', 'l', 'large', 'xl', 'xxl', 'xxxl'));
    return $comp[strtolower($a)] - $comp[strtolower($b)];
}

uasort($array, 'sizeSorter');

print_r($array);


Output:
1
2
3
4
5
6
7
Array
(
    [63-507cddcd16d9786abafccfa78b19acf8] => S
    [64-507cddcd16d9786abafccfa78b19acf8] => M
    [65-507cddcd16d9786abafccfa78b19acf8] => L
    [66-507cddcd16d9786abafccfa78b19acf8] => XL
)


Create a new paste based on this one


Comments: