Me and one of my friends have recently written a paper and we have almost the same contribution. Is there any conventional way to express this and show this ? How do we sort the name of the authors in such a case?
The most common is to list in alphabetical order (in fact you can decide whatever you want) and then write a statement in the acknowledgement to the effect that "both authors have contributed equally to the paper".
In one (odd) example I know of names were listed in reverse alphabetical order. The "first author" was the senior and the second his (in this case) graduate student. They then stated in the acknowledgement that contributions were equal. So in this case the senior scientist wanted the publication listed under his name although it would have been more logical with the students name first. So it is obvious there may be several "reasons" to list other than alphabetical but I think alphabetical should be the way to go. At least in my subject order typically signifies contribution and an inverse order would be a very strong signal.
I have also seen authors who have taken turns to be first when they frequently publish together. That could be a reasonable (fair) alternative when it happens.