I would write a script that would rearrange the rows in your text file, one by one. I had a similar problem a while back. Basically what I did is this:
$delim = "\t"; // change this to whatever your field delimiter is
$fileArray = file("something.txt");
for ($i=0; $i<=count($fileArray)-1; $i++)
{
list($lastname, $middlename, $firstname) = split($delim, $fileArray[$i]);
$output .= "$firstname\t$middlename\t$lastname\n";
}
$fp = fopen("newsomething.txt", "w+");
fwrite($fp, $output);
fclose($fp);
This should work for you, unless I completely misunderstood the problem (and it wouldn't be the first time that's happened). Obivously, if you want the fields to be delimited by something other than \t and your lines to be terminated by \n, make the needed changes in the $output var.
Hope this helps.