refact($compile): custom sort directives for better performance

please see and reopen this issue https://github.com/angular/angular.js/issues/8355