sort fix for complex headers