Sorting an array of objects by a property which may be missing
Here's a single-pass example. Very similar to @janos' code (which has a good complexity analysis). The only difference is in how various cases with undefined are treated.

function sort(searchResult) {
  return searchResult.sort((tc1, tc2) =&gt; {

    const tc1RefUndefined = tc1.reference == null;
    const tc2RefUndefined = tc2.reference == null;
    if (tc1RefUndefined || tc2RefUndefined) {
      if (tc1RefUndefined &amp;&amp; tc2RefUndefined) {
        return 0;

        // or if consistency in grouping (within the groups) is necessary:
        // return tc1.otherProperty comparedTo tc2.otherProperty
      } else if (tc1RefUndefined) {
        return -1;
      } else {
        return 1;
      }
    }

    return tc1.reference.localeCompare(tc2.reference);
  });
}