Partition a list based on columns
- To: mathgroup at smc.vnet.net
- Subject: [mg119660] Partition a list based on columns
- From: StatsMath <stats.math8 at gmail.com>
- Date: Thu, 16 Jun 2011 04:02:12 -0400 (EDT)
Hi All, I am looking for help in partition a list based on columns. For ex, given a list {{3,1},{2,4}}, I want to sort it and then partition it along columns. So for the given example, I want the answer to be, {{1,3},{2,4}}. Right now If I try, Partition[Sort[Flatten[{{3,1},{2,4}}]]],2], I get {{1,2},{3,4}}. Looking at doc for Partition[], it doesn't seem to support aligning rows on columns. I can do it in a For[] loop, but that seems un- mathematica like, is there a good functional way to do this?? ------------ What would be a good way to line up elements in a list in a diagonal fashion, for ex: from Range[9] want to create the follwing matrix: 1 2 4 3 5 7 6 8 9 Thanks in advance!
- Follow-Ups:
- Re: Partition a list based on columns
- From: Heike Gramberg <heike.gramberg@gmail.com>
- Re: Partition a list based on columns