oslon Posted October 23 Share Posted October 23 int[][] wh2d = { {0, 34}, {1, 28}, {2, 20}, {3, 31}, {4, 32}, {5, 28}, {6, 37}, {7, 41} }; I need to sort this based on 34.28,20...etc. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 23 Share Posted October 23 You need to use a custom sort function with usort() usort($array['wh2d'], fn($a,$b)=>$a[1]<=>$b[1]); or, if you are uncomfortable with that syntax, ... usort($array'wh2d', 'mysort'); function mysort($a, $b) { return $a[1] <=> $b[1]; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.