fix branch sorting