INDEX/MATCH will do it in any direction of search.
So for your example of B --> A:
The MATCH returns the matching row's number. It's optional to use the third Criterion of 0. When it comes to the fourth VLOOKUP criterion, which searches for an exact match, the value 0 is equivalent to FALSE. The match that is less than or equal to the criteria, like VLOOKUP's TRUE, will be returned if the data is sorted and the default value is 1.
The INDEX determines the right value from that and returns it.