[gardening] Fix ubsan issue where nullptr is passed to qsort()
[gardening] Fix ubsan issue where nullptr is passed to qsort()

TEST=Fixes various ubsan failures.

Change-Id: Iaed0f012604e0fa6bf8aebf20e858bf482b7c336
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210720
Reviewed-by: Tess Strickland <cce218d042444252b7ac446d60910fca7732559c@google.com>
Commit-Queue: Martin Kustermann <a35dd5b79fac84b2bb3b026a16b8becc55af5961@google.com>

dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk,dart-lang/sdk