Your sort callback is incorrect. It needs to return a negative number if the first item goes before the second, a positive number if the second goes before the first, or 0 if they're "the same." Instead, your function is returning booleans, which will get coerced to 1 (if true) or 0 (if false), which won't sort things correctly.

String#localeCompare is handy for sorting strings. It will consider "" "earlier" than anything with content, though, so we have to special-case that: