Using @MartinScharrer's rather new collcell
package, we can collect the body of each cell and save it with a given label, then typeset the cells in a different order, calling each label. Namely, the code below defines two column types: s{<label>}
(for save) and o{<label>}
(for output).
One drawback is that you need to put a whole bunch of &
at the end of each line to allow typesetting to occur (as many &
as you have columns). This can also be used to e.g. double one column, or remove one column.
\documentclass{article}
\usepackage{collcell}
\usepackage{array}
\newcommand{\newcelltoksifnew}[1]{%
\expandafter\ifx\csname cell@toks@#1\endcsname\relax
\expandafter\newtoks\csname cell@toks@#1\endcsname
\fi}
\newcolumntype{s}[1]{%
>{\unskip\newcelltoksifnew{#1}%
\collectcell{\global\csname cell@toks@#1\endcsname}}%
c%
<{\endcollectcell}%
@{}%
}
\newcolumntype{o}[1]{%
>{\the\csname cell@toks@#1\endcsname}%
c%
}
\begin{document}
\begin{table}\centering
\begin{tabular}{|c|c|c|}
a & c & b \\
AAAAA&CCCCC&BBBBB
\end{tabular}
\begin{tabular}{s{A}s{B}s{C}|o{A}|o{C}|o{B}|}
a & b & c &&&\\
AAAAA&BBBBB&CCCCC&&&
\end{tabular}
\caption{Comparing two tables to see that the spacing is not affected.}
\end{table}
\end{document}
datatool
which manipulate CSV data.