Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1737

Re: SortBy

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: SortBy
Date 2011-04-16 11:36 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iobv0f$bfe$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 4/15/11 at 3:56 AM, graser@gmail.com (graser) wrote:

>I have a simple question for you.

>Let's say there is a list like

>KS = {{300, 48, 2}, {500, 23, 5}, {120, 55, 7}, {40, 32, 1}};

>I want to sort it by second element.

>I can use

>Sort[KS, #2[[2]] > #1[[2]] &]

>It gives out like

>{{500, 23, 5}, {40, 32, 1}, {300, 48, 2}, {120, 55, 7}}

>But if I want to use SortBy, how to do that?

>SortBy[KS, ??]

In[2]:= SortBy[ks, #[[2]] &]

Out[2]= {{500, 23, 5}, {40, 32, 1}, {300, 48, 2}, {120, 55, 7}}

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: SortBy Bill Rowe <readnews@sbcglobal.net> - 2011-04-16 11:36 +0000

csiph-web