filipex_27 Posted July 9, 2012 at 09:04 PM Report Share #468106 Posted July 9, 2012 at 09:04 PM Boas tenho um array do tipo: Array ( [postO1] => Array ( [des1] => Array ( [Jun] => 123 [s13] => 12 [31] => 32 ) [des2] => Array ( [Jun] => 332 [s14] => 13 [23] => 42 ) [des3] => Array ( [Jun] => 200 [s12] => 21 [24] => 76 ) ) [postO2] => Array ( [des1] => Array ( [Jun] => 97 [s13] => 3 [31] => 22 ) [des2] => Array ( [Jun] => 37 [s13] => 34 [31] => 65 ) [des3] => Array ( [Jun] => 98 [s13] => 65 [31] => 96 ) ) [postO3] => Array ( [des1] => Array ( [Jun] => 86 [s13] => 2 [31] => 43 ) [des2] => Array ( [Jun] => 63 [s13] => 253 [31] => 86 ) [des3] => Array ( [Jun] => 874 [s13] => 23 [31] => 1 ) ) ) agora queria ordená-lo pelo valor da chave "Jun"... o que já tenho é algo do género... function max3D($item1,$item2) { if ($item1['Jun'] == $item2['Jun']) return 0; return ($item1['Jun'] < $item2['Jun']) ? 1 : -1; } $postos=array('POSTO1','POSTO2','POSTO3'); foreach($postos as $pt){ usort($p[$pt], "max3D"); } quanto executo...fico com algo do tipo... Array ( [postO1] => Array ( [0] => Array ( [Jun] => 332 [s14] => 13 [23] => 42 ) [1] => Array ( [Jun] => 200 [s12] => 21 [24] => 76 ) [2] => Array ( [Jun] => 123 [s13] => 12 [31] => 32 ) ) [postO2] => Array ( [0] => Array ( [Jun] => 98 [s13] => 65 [31] => 96 ) [1] => Array ( [Jun] => 97 [s13] => 3 [31] => 22 ) [2] => Array ( [Jun] => 37 [s13] => 34 [31] => 65 ) ) [postO3] => Array ( [0] => Array ( [Jun] => 874 [s13] => 23 [31] => 1 ) [1] => Array ( [Jun] => 86 [s13] => 2 [31] => 43 ) [2] => Array ( [Jun] => 63 [s13] => 253 [31] => 86 ) ) ) ou seja para cada posto perco a designação...o que eu não queria...alguma pista? Obrigado! Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 9, 2012 at 09:12 PM Report Share #468107 Posted July 9, 2012 at 09:12 PM usa a função uasort IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
pmg Posted July 9, 2012 at 09:14 PM Report Share #468108 Posted July 9, 2012 at 09:14 PM (edited) Experimenta a funcao uasort em vez de usort. Edited July 9, 2012 at 09:15 PM by pmg What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
filipex_27 Posted July 9, 2012 at 09:20 PM Author Report Share #468109 Posted July 9, 2012 at 09:20 PM Epá vocês são os maiores pá...e uma solução tão simples...rais parta! Muito Obrigado! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now