How to sort columns in excel(csv) file

i want sort columns with headers based on another file headers
file1
eg: i'm having an empty file with only coumn names like

lastname firstname title expirydate stlcno status etc...

another file with same column names and some other as well but in different order...
file2
eg:firstname expirydate stlcno lastname status ....

file2 is having data i want the file1 shud populate with the data in file2 apprpraitely or just sort the file2 sames as file1...

i am very much new to shell scripting please provide an example with code.....awaiting reply

$
$
$ cat f0
c3,c1,c2,c4
$
$
$ cat f1
c1,c2,c3,c4
a,b,c,d
e,f,g,h
i,j,k,l
m,n,o,p
q,r,s,t
$
$
$
$ perl -ne 'chomp; close ARGV if eof;
            if ($ARGV eq "f0") {@x = split/,/}
            elsif ($.==1) {@h = split/,/; print join(",",@x),"\n"}
            else {@d = split/,/; foreach $i(0..$#d) {$y{$h[$i]} = $d[$i]}
                  foreach $i(0..$#x) {push @p, $y{$x[$i]}}
                  print join(",",@p),"\n"; @p = ()}
           ' f0 f1
c3,c1,c2,c4
c,a,b,d
g,e,f,h
k,i,j,l
o,m,n,p
s,q,r,t
$
$

tyler_durden

Hi durden_tyler,

Thanks Very Much but i have to use unix script for this ....could help me