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