我从 MySQL 查询生成了一个数组,然后我使用 subval_sort() 重新排序。这很好用,除非在排序中出现字母“E”。在这些情况下,其中带有“E”的值首先出现。我有四个发生这种情况的实例,但在其他任何地方(这是一个非常大的站点,顺便说一句),排序工作正常。
这是我的数组,因为它是从 db 查询生成的:
Array (
[] => Array ( [Item #] => 091055070 [Size Code] => 7 [D Diameter] => 5/8" [d Small Diameter (Pilot) ] => 1/4" [L Length] => 3 1/4" )
[1] => Array ( [Item #] => 091055060 [Size Code] => 6 [D Diameter] => 1/2" [d Small Diameter (Pilot) ] => 7/32" [L Length] => 3" )
[2] => Array ( [Item #] => 091055050 [Size Code] => 5 [D Diameter] => 7/16" [d Small Diameter (Pilot) ] => 3/16" [L Length] => 2 3/4" )
[3] => Array ( [Item #] => 091055040 [Size Code] => 4 [D Diameter] => 5/16" [d Small Diameter (Pilot) ] => 1/8" [L Length] => 2 1/8" )
[4] => Array ( [Item #] => 091055030 [Size Code] => 3 [D Diameter] => 1/4" [d Small Diameter (Pilot) ] => 7/64" [L Length] => 2" )
[5] => Array ( [Item #] => 091055020 [Size Code] => 2 [D Diameter] => 3/16" [d Small Diameter (Pilot) ] => 5/64" [L Length] => 1 7/8" )
[6] => Array ( [Item #] => 091055010 [Size Code] => 1 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => 3/64" [L Length] => 1 1/4" )
[7] => Array ( [Item #] => 0910550E0 [Size Code] => 0 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => 1/32" [L Length] => 1 1/4" )
[8] => Array ( [Item #] => 091055080 [Size Code] => 8 [D Diameter] => 3/4" [d Small Diameter (Pilot) ] => 5/16" [L Length] => 3 1/2" )
[9] => Array ( [Item #] => 0910550D0 [Size Code] => 00 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .025" [L Length] => 1 1/4" )
[10] => Array ( [Item #] => 0910550C0 [Size Code] => 000 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .020" [L Length] => 1 1/4" )
[11] => Array ( [Item #] => 0910550B0 [Size Code] => 0000 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .015" [L Length] => 1 1/4" )
[12] => Array ( [Item #] => 0910550A0 [Size Code] => 00000 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .010" [L Length] => 1 1/4" ) )
我运行这条线:
$productArray = subval_sort($productArray,'Item #');
然后就出来了:
Array (
[0] => Array ( [Item #] => 0910550E0 [Size Code] => 0 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => 1/32" [L Length] => 1 1/4" )
[1] => Array ( [Item #] => 091055010 [Size Code] => 1 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => 3/64" [L Length] => 1 1/4" )
[2] => Array ( [Item #] => 091055020 [Size Code] => 2 [D Diameter] => 3/16" [d Small Diameter (Pilot) ] => 5/64" [L Length] => 1 7/8" )
[3] => Array ( [Item #] => 091055030 [Size Code] => 3 [D Diameter] => 1/4" [d Small Diameter (Pilot) ] => 7/64" [L Length] => 2" )
[4] => Array ( [Item #] => 091055040 [Size Code] => 4 [D Diameter] => 5/16" [d Small Diameter (Pilot) ] => 1/8" [L Length] => 2 1/8" )
[5] => Array ( [Item #] => 091055050 [Size Code] => 5 [D Diameter] => 7/16" [d Small Diameter (Pilot) ] => 3/16" [L Length] => 2 3/4" )
[6] => Array ( [Item #] => 091055060 [Size Code] => 6 [D Diameter] => 1/2" [d Small Diameter (Pilot) ] => 7/32" [L Length] => 3" )
[7] => Array ( [Item #] => 091055070 [Size Code] => 7 [D Diameter] => 5/8" [d Small Diameter (Pilot) ] => 1/4" [L Length] => 3 1/4" )
[8] => Array ( [Item #] => 091055080 [Size Code] => 8 [D Diameter] => 3/4" [d Small Diameter (Pilot) ] => 5/16" [L Length] => 3 1/2" )
[9] => Array ( [Item #] => 0910550A0 [Size Code] => 00000 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .010" [L Length] => 1 1/4" )
[10] => Array ( [Item #] => 0910550B0 [Size Code] => 0000 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .015" [L Length] => 1 1/4" )
[11] => Array ( [Item #] => 0910550C0 [Size Code] => 000 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .020" [L Length] => 1 1/4" )
[12] => Array ( [Item #] => 0910550D0 [Size Code] => 00 [D Diameter] => 1/8" [d Small Diameter (Pilot) ] => .025" [L Length] => 1 1/4" ) )
有任何想法吗?提前致谢