Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15605 > unrolled thread
| Started by | Peter Breitfeld <phbrf@t-online.de> |
|---|---|
| First post | 2011-02-10 10:21 +0000 |
| Last post | 2011-02-10 10:21 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Sorting nested lists with strings Peter Breitfeld <phbrf@t-online.de> - 2011-02-10 10:21 +0000
| From | Peter Breitfeld <phbrf@t-online.de> |
|---|---|
| Date | 2011-02-10 10:21 +0000 |
| Subject | Re: Sorting nested lists with strings |
| Message-ID | <ij0e7g$9c1$1@smc.vnet.net> |
Paperorbifold wrote:
> I've a nested list of this kind:
> list={{"Paul",23},{"Amanda",55},{"Carl",32},...}
> Suppose I want to perform an alphabetic sort on the first element. Which is
> the condition I've to write in Sort[list,...]?
> Actually Sort[list] automatically operates on the second element.
> Thanks.
>
> --
> ...and I will make them pay for\nwhat they've done! (J.L. Picard)
>
You may try
list = {{"Paul", 23}, {"Gustaf", 45}, {"Wilhelm", 13}, {"Arno", 45}};
list[[ Ordering[First/@list] ]]
Out={{"Arno", 45}, {"Gustaf", 45}, {"Paul", 23}, {"Wilhelm", 13}}
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web