Right now source locations from different translation units can not be compared.
This is a problem for an upcoming feature in the Static Analyzer, the cross translation unit support (https://reviews.llvm.org/D30691).
It would be great to be able to sort the source locations. To achieve this I factored out some code from isBeforeInTranslationUnit to be able to determine whether to source locations are from the same translation unit. Note that, in our use-case, these source locations are imported and from the same source manager.