To play with the author order is not fair and perhaps unethical if it unfairly changes the picture of the intellectual contribution to the paper. Unfortunately, the ordering is largely an internal problem within the group since only that group can assess the appropriate ordering. So, discussing the problem within the author group would be the first choice of action. When doing so you need to have a good argument for why the division of authorship should look the way you see it and have good arguments for that. The core problem therefore seems to be a lack of communication.
It is a good idea (necessary) to discuss a system for ordering of authorship. There are guidelines for authorship and contributorship based on the Vancouver Protocol. You can also look at the post Paper contributions and first authorship. Requirements for authorship are quite strict and each author group needs to work out how authorship should be divided along a clear set of rules. An example of how such a discussion is given on, for example, the site AuthorOrder.
There are cases when authorship changes can be unethical, but those mostly concern the first authorship so I do not sense this is the main problem in your case. Nevertheless, for some input on disputes, I recommend looking at COPE's How to handle authorship disputes:a guide for new researchers.
If you do not think you can discuss the changes with the first order, then you have to learn from the experience and insist on discussing the grounds for authorship and ordering in future collaborations.