PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20



PHP Snippet 1:

uksort($param, 'strcmp');

$url = array();
foreach ($param as $key => $val) {

    $key = str_replace("%7E", "~", rawurlencode($key));
    $val = str_replace("%7E", "~", rawurlencode($val));
    $url[] = "{$key}={$val}";
}

PHP Snippet 2:

SellerSKUList.SellerSKU.10=4574&
SellerSKUList.SellerSKU.11=4575&
SellerSKUList.SellerSKU.18=4582&
SellerSKUList.SellerSKU.19=4583&
SellerSKUList.SellerSKU.1=4565&
SellerSKUList.SellerSKU.20=4584&
SellerSKUList.SellerSKU.2=4566

PHP Snippet 3:

array_multisort(array_map(fn($v) => strtok($v, '='), $array), $array);
var_export($array);