To my way of thinking, only a solution such as LanX’s cmp_undef2 ... with appropriate and generous comments ... would pass my code-review. This is very clearly a case for a custom sort-comparison subroutine, which is prepared to handle undef as a legitimate value for $a and/or $b. The subroutine should be a distinct sub (since it is unusual), and carefully described in comments.
Although I do not ever “down”-vote, some of these solutions are, IMHO, very clearly bad ones, the likes of which I have certainly seen in production code. But please do not take this statement personally: I am talking about the practice. These attempts at solution “cabbage up a way to produce ‘the right answer,’” at least in every case (if any) that the author has tested, but they do not describe the situation, such that it can be readily shown that they will in fact work for all possible cases without relying on curiosities of the language implementation. The accurate description of this problem is that the list can contain undefined entries, and that these should be sorted to the front of the list. A sort-compare subroutine is the prescribed way to do this, and therefore, to my review, the only acceptable one.