I did some studies regarding the element rateSortOrder. Here are the available values:
SERVICENAMETRADITIONAL - data in order of highest to lowest service (Default)
COMMITASCENDING - data in order of ascending delivery committment
COMMITDESCENDING - data in order of descending delivery committment.
The last two sorting options are both based on the shipping speed, not by the quoted price. You may need to change the code for your special needs.
You can probably try my code as the following (Bubble Sort). So the ground will be the first, then the rest will be sorted ascending by price.
Please put the following code on the top of the file.
if (!function_exists('fedex_sort')) {
function fedex_sort ($a, $b) {
$c = (float)$a['cost'];
$d = (float)$b['cost'];
$e = 'Ground';
if ($c==$d) return 0;
if (strpos($a['title'], $e) !== false) return -1;
if (strpos($b['title'], $e) !== false) return 1;
return ($c>$d?1:-1);
}
}
Then put the following line before "$quotes['methods'] = $methods;"
usort($methods,'fedex_sort');