protected function applyOrderByToQuery(PhabricatorCursorPagedPolicyAwareQuery $query, array $standard_values, $order)
 {
     if (substr($order, 0, 7) === 'custom:') {
         $list = $this->getCustomFieldList();
         if (!$list) {
             $query->setOrderBy(head($standard_values));
             return;
         }
         foreach ($list->getFields() as $field) {
             $key = $this->getKeyForCustomField($field);
             if ($key === $order) {
                 $index = $field->buildOrderIndex();
                 if ($index === null) {
                     $query->setOrderBy(head($standard_values));
                     return;
                 }
                 $query->withApplicationSearchOrder($field, $index, false);
                 break;
             }
         }
     } else {
         $order = idx($standard_values, $order);
         if ($order) {
             $query->setOrderBy($order);
         } else {
             $query->setOrderBy(head($standard_values));
         }
     }
 }