Re: Re: Select Maximum Value
- To: mathgroup at smc.vnet.net
- Subject: [mg107954] Re: [mg107948] Re: Select Maximum Value
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 4 Mar 2010 05:24:53 -0500 (EST)
- Reply-to: hanlonr at cox.net
A = {{{1, 2}, {2, 1}, {3, 4}}, {{1, 5}, {2, 1}, {3, 2}}}; SortBy[#, Last][[-1]] & /@ A {{3, 4}, {1, 5}} Bob Hanlon ---- graser <graser at gmail.com> wrote: ============= On Mar 2, 8:01 am, Patrick Scheibe <psche... at trm.uni-leipzig.de> wrote: > Hi, > > it is simply > > A = {{2, 4, 1, 3, 2, 2}, {4, 7, 9, 1, 2, 4}}; > > Max /@ A > > and your code is not working at all. > > Cheers > Patrick > > Am Mar 2, 2010 um 9:36 AM schrieb graser: > > > > > Hi > > > I want to pick up the maximum value of each list in the Array > > > A={{2, 4, 1, 3, 2, 2}, {4,7,9,1,2,4}} > > > I can do it in two steps.. > > > B=Table[Sort[A[[i]], #1>#2&], {i, 1, Length[A]}]; > > > C=Table[B[i], {i, 1, Length[B]}]; > > > But is there any way I can do it in just one step with Select function > > or any thing else? > > > Thanks Thanks for all of your comments.. Here I have more question for you.. If Array has A={{1,2},{2,1},{3,4}},{{1,5},{2,1},{3,2}}.. Then If I want to pick up the list which has maximum value in second column, So my result should be {{3,4},{1,5}}, can I still use the Max? It just give the maximum value in first column like {4,5} Or I have to use the multiple steps like B = Table[Sort[A[[i]], #1[[2]] > #2[[2]] &], {i, 1, Length[A]}]; CD = Table[B[[i, 1]], {i, 1, Length[B]}];