I would start by looking in Blizzard's function BuffButton_UpdateAnchors in
FrameXML/BuffFrame.lua.It shows the way how the default interface handles this and provides a good start for modifying it.
Maybe just copying this function in your addon and replacing "LEFT" with "RIGHT" (and the other way round) should do it? Ah, and don't forget to change the X-offset in the SetPoint's.
Code:
So
buff:SetPoint("RIGHT", getglobal(buttonName..(index-1)), "LEFT", -5, 0);
would become
buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "LEFT", 5, 0);
Just an (untested) idea which came to my mind