I think you would have better luck with your problem by posting it to stackoverflow.com. You would want to better define the problem, clarify what you mean by matrix format (2-d array?) by maybe giving a short example of what the matrix format would look like. I am assuming you already have some tool that does the pivoting, but if that is where you are getting hung up, I'm sure there are libraries out there that would assist with that. Good luck!