Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 5570)
+++ wp-includes/link-template.php	(working copy)
@@ -77,6 +77,8 @@
 		$category = '';
 		if (strpos($permalink, '%category%') !== false) {
 			$cats = get_the_category($post->ID);
+			if ( $cats )
+				usort($cats, '_get_the_category_usort_by_ID'); // order by ID
 			$category = $cats[0]->category_nicename;
 			if ( $parent=$cats[0]->category_parent )
 				$category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
Index: wp-includes/category-template.php
===================================================================
--- wp-includes/category-template.php	(revision 5570)
+++ wp-includes/category-template.php	(working copy)
@@ -83,6 +83,15 @@
 	return strcmp($a->category_name, $b->category_name);
 }
 
+function _get_the_category_usort_by_ID($a, $b) {
+	if ( $a->cat_ID > $b->cat_ID )
+		return 1;
+	elseif ( $a->cat_ID < $b->cat_ID )
+		return -1;
+	else
+		return 0;
+}
+
 function get_the_category_by_ID($cat_ID) {
 	$cat_ID = (int) $cat_ID;
 	$category = &get_category($cat_ID);

