Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: sort

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30016] Re: [mg29997] Re: [mg29991] sort
  • From: "Mr. Wizard" <gleam at flashmail.com>
  • Date: Sat, 21 Jul 2001 16:16:42 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Bob, I think I've got a much faster way to accomplish the same thing.

Look at http://aerie.net/mma/sorting.nb

You will need http://aerie.net/mma/clk.tif


Paul


>sortByCol[l_List, n_Integer] :=
>     Sort[l, #1[[n]] <= #2[[n]]&];
>
>mat = Table[Random[Integer, {1, 4}], {10}, {10}];
>
>sortByCol[mat, 3]
>
>To sort by column 3 with column 4 breaking ties
>
>sortByCol[sortByCol[mat, 4], 3]
>
>If more than two columns are to be used
>
>Fold[sortByCol[#1, #2]&, mat, {5, 4, 3}]
>
>
>Bob Hanlon
>Chantilly, VA  USA



  • Prev by Date: Embedding Excel (COM Objects) in Notebook
  • Next by Date: Filename as Function Argument
  • Previous by thread: RE: sort
  • Next by thread: Integrate[Sqrt[Tan[x]], {x, 0, 1}] -- approx ??