int (@NotNull GitRemoteBranch o1, @NotNull GitRemoteBranch o2) { String remoteName1 = o1.getRemote().getName(); String remoteName2 = o2.getRemote().getName(); int remoteComparison = remoteName1.compareTo(remoteName2); if (remoteComparison != 0) { if (remoteName1.equals(GitRemote.ORIGIN)) { return -1; } if (remoteName2.equals(GitRemote.ORIGIN)) { return 1; } return remoteComparison; } return o1.getNameForLocalOperations().compareTo(o2.getNameForLocalOperations()); }