array_multisort 関数で遊んでいますが、持っている配列で機能させるのに苦労しています。
これは、ソートしようとしている多次元配列の var ダンプです。
array(2) {
[1]=> array(6) {
["totalprice"]=> float(103.32)
["itemsprice"]=> float(83.33)
["deliveryprice"]=> float(19.99)
["qualityscore"]=> int(100)
["reliabilityscore"]=> int(100)
["itemtemplates"]=> array(4) {
[1]=> array(3) {
["price"]=> float(374)
["qty"]=> int(200)
["name"]=> string(17) "English A2 Poster"
}
[3]=> array(3) {
["price"]=> float(374)
["qty"]=> int(500)
["name"]=> NULL
}
[6]=> array(3) {
["price"]=> float(83.333333333333)
["qty"]=> int(100)
["name"]=> string(16) "French A3 Poster"
}
[5]=> array(3) {
["price"]=> float(83.333333333333)
["qty"]=> int(5000) ["name"]=> NULL
}
}
}
[2]=> array(6) {
["totalprice"]=> float(103.32)
["itemsprice"]=> float(83.33)
["deliveryprice"]=> float(19.99)
["qualityscore"]=> int(80)
["reliabilityscore"]=> int(100)
["itemtemplates"]=> array(4) {
[1]=> array(3) {
["price"]=> float(374)
["qty"]=> int(200)
["name"]=> string(17) "English A2 Poster"
}
[3]=> array(3) {
["price"]=> float(374)
["qty"]=> int(500)
["name"]=> NULL
}
[6]=> array(3) {
["price"]=> float(83.333333333333)
["qty"]=> int(100)
["name"]=> string(16) "French A3 Poster"
}
[5]=> array(3) {
["price"]=> float(83.333333333333)
["qty"]=> int(5000) ["name"]=> NULL
}
}
}
[3]=> array(6) {
["totalprice"]=> float(83.32)
["itemsprice"]=> float(63.33)
["deliveryprice"]=> float(19.99)
["qualityscore"]=> int(60)
["reliabilityscore"]=> int(40)
["itemtemplates"]=> array(4) {
[1]=> array(3) {
["price"]=> float(374)
["qty"]=> int(200)
["name"]=> string(17) "English A2 Poster"
}
[3]=> array(3) {
["price"]=> float(374)
["qty"]=> int(500)
["name"]=> NULL
}
[6]=> array(3) {
["price"]=> float(83.333333333333)
["qty"]=> int(100)
["name"]=> string(16) "French A3 Poster"
}
[5]=> array(3) {
["price"]=> float(83.333333333333)
["qty"]=> int(5000) ["name"]=> NULL
}
}
}
}
合計価格の ASC で並べ替え、次に品質スコアの DESC で並べ替える必要があります。
私は次のことを試しました:
$sorted = array_multisort($array['totalprice'], SORT_ASC, SORT_NUMERIC,
$array['qualityscore'], SORT_NUMERIC, SORT_DESC);
残念ながら、それはうまくいきません。誰かがこの機能にもう少し精通しており、どこが間違っているのか知っているかもしれませんか? または、この機能に代わる簡単な方法がある場合は?
前もって感謝します!